Closed m1cypher closed 2 months ago
Hello! So you're combining part of this template with your own? Could you provide a code block of what the frontmatter looks like in your template?
So I am combining it with my own template. I was just taking the cssclasses from yours and adding it to mine. This is what my front matter looks like textually.
---
Location: Home
tags:
- daily-reviews
aliases:
Enjoyment:
Why:
Code:
Workout:
Weight:
Post-workout-weight:
Percentage:
Post-workout-percent:
Meditation: 1
Reading:
Home-Improvement:
Homelab: 1
creation date: 2024-04-19 08:16
cssclasses:
- <% "- " + tp.date.now("dddd", 0, tp.file.title, "YYYY-MM-DD").toLowerCase() %>
While it looks fine in text, it doesn't when you flip back to standard view
Ah, I see the problem! I'm already accounting for the hyphen inside the templater code. If you remove the hyphen beforehand, it should work properly:
cssclasses:
<% "- " + tp.date.now("dddd", 0, tp.file.title, "YYYY-MM-DD").toLowerCase() %>
- other-example-class
Obsidian shows an issue with this in the live preview for the template because it's technically not valid YAML, but it works fine as a template. The reason I have the hyphen as part of the template code is so that the whole thing doesn't show up as an autofill option for other note properties.
Gotcha. Made that change and it does provide a day, but it breaks Obsidian's front matter.
Corrected example of my template
Creation of tomorrow (Saturday) note
I am assuming this error is probably why the color's also are not showing up.
The invalid YAML (red text) is normal for the template, but your final note shouldn't be breaking. I also just realized that you only have the CSS class for the current day, when you also need the daily
class in order for the theme to work. So in the end, it should contain both classes like this:
cssclasses:
- daily
<% "- " + tp.date.now("dddd", 0, tp.file.title, "YYYYMMDD").toLowerCase() %>
The other half of reason why it isn't working here is because the hyphen syntax is for indented lists, so if you had a class on the same line (ex. cssclasses: - saturday
) it wouldn't work with the hyphen in there. But since you need both the daily
and "day of the week" classes for the theme, you won't run into that particular issue with this setup - just thought I'd mention it.
Here's what my template looks like in source mode, by the way (ignore the image-borders class):
For whatever reason, I didn't see this last comment. As soon as I added the "daily" class the properties error went away. However, I am still not getting the colors. I think it is just a theme issue so I can work on the CSS now that I see that daily needed to be added. Thank you.
For reference, the solution is (in source mode you can copy and past the lines below modifying the date portion as needed):
cssclasses:
Love this idea. I recently went to install this and when I add the cssclass information to my daily note template, Obsidian will add a space in the inline javascript so it will not work.
I have a feeling it is user error so can you look into it or maybe tell my dumbass how to get around that? Thank you.