-
Star
(191)
You must be signed in to star a gist -
Fork
(38)
You must be signed in to fork a gist
-
-
Save dannberg/48ea2ba3fc0abdf3f219c6ad8bc78eb6 to your computer and use it in GitHub Desktop.
--- | |
created: <% tp.file.creation_date() %> | |
--- | |
tags:: [[+Daily Notes]] | |
# <% moment(tp.file.title,'YYYY-MM-DD').format("dddd, MMMM DD, YYYY") %> | |
<< [[Timestamps/<% tp.date.now("YYYY", -1) %>/<% tp.date.now("MM-MMMM", -1) %>/<% tp.date.now("YYYY-MM-DD-dddd", -1) %>|Yesterday]] | [[Timestamps/<% tp.date.now("YYYY", 1) %>/<% tp.date.now("MM-MMMM", 1) %>/<% tp.date.now("YYYY-MM-DD-dddd", 1) %>|Tomorrow]] >> | |
--- | |
### 📅 Daily Questions | |
##### 🌜 Last night, after work, I... | |
- | |
##### 🙌 One thing I'm excited about right now is... | |
- | |
##### 🚀 One+ thing I plan to accomplish today is... | |
- [ ] | |
##### 👎 One thing I'm struggling with today is... | |
- | |
--- | |
# 📝 Notes | |
- <% tp.file.cursor() %> | |
--- | |
### Notes created today | |
```dataview | |
List FROM "" WHERE file.cday = date("<%tp.date.now("YYYY-MM-DD")%>") SORT file.ctime asc | |
``` | |
### Notes last touched today | |
```dataview | |
List FROM "" WHERE file.mday = date("<%tp.date.now("YYYY-MM-DD")%>") SORT file.mtime asc | |
``` |
@Pdfulkar it looks like Templater is not properly executing to turn the template into a note. For one-offs, you can use the command palette to trigger Templater: Replace templates in the active file
or make sure your settings are adjusted so that Templater runs when you create a new note from a template.
@Pdfulkar it looks like Templater is not properly executing to turn the template into a note. For one-offs, you can use the command palette to trigger
Templater: Replace templates in the active file
or make sure your settings are adjusted so that Templater runs when you create a new note from a template.
Yup Now It's Working As it should be
thanks @dannberg
This version of the template has issues when used in conjunction with obsidian-calendar-plugin.
The Calendar plugin allows users to click on any date in the calendar to create a diary entry for that day. This is very convenient for busy people to backfill their diary entries from the previous day. In such cases, using tp.date.now()
no longer represents the intended time.
The only reliable source of the date string is the file name. Whether using the default Daily Notes or the Calendar plugin, the file names of the notes they create are the target dates we want.
Assuming we set the Date format in the settings of the Daily Notes plugin to "YYYY-MM-DD", the template can be designed as follows:
<%*
const fileDateStr = tp.file.title;
const fileMoment = window.moment(fileDateStr, "YYYY-MM-DD");
%># <% fileDateStr %>
<< [[<% fileMoment.clone().subtract(1, 'day').format("YYYY-MM-DD") %>|Yesterday]] | [[<% fileMoment.clone().add(1, 'day').format("YYYY-MM-DD") %>|Tomorrow]] >>
I had the same problem described by @Pdfulkar and @victorwoo on ephemeral notes as well.
A good solution is to adapt Victor's approach to add the journaling date to the frontmatter.
E.g.:
---
created: <% tp.file.creation_date() %>
<%*
const journalDate = window.moment(tp.file.title, "YYYY-MM-DD");
%>
journal-date: <% journalDate.format("YYYY-MM-DD") %>
---
Then you can use the Dataview JavaScript API to retrieve ephemeral notes. This also allows you to completely skip the ephemeral note headers when you haven't created or modified any notes on that day.
```dataviewjs
const journalDate = dv.current().file.frontmatter["journal-date"];
const created = dv.pages()
.where(p => p.file.cday.toISODate() === journalDate)
.sort(p => p.file.ctime, 'asc');
const modified = dv.pages()
.where(p => p.file.mtime.toISODate() === journalDate)
.sort(p => p.file.mtime, 'asc');
if (created.length > 0 || modified.length > 0) {
dv.span("---");
}
if (created.length > 0) {
dv.header(2, "Notes created today");
dv.list(created.map(p => p.file.link));
}
if (modified.length > 0) {
dv.header(2, "Notes last touched today");
dv.list(modified.map(p => p.file.link));
}
```
You can also adapt Victor's example above for navigation:
<< [[<% journalDate.clone().subtract(1, 'day').format("YYYY-MM-DD-dddd") %>|Yesterday]] | [[<% journalDate.clone().add(1, 'day').format("YYYY-MM-DD-dddd") %>|Tomorrow]] >>
But I'm a huge fan of the Journals plugin, which makes navigation as simple as:
```journal-nav
```
Hi there, thanks for sharing. I just ran into the same issue as @1artist with the parsing error. Looks like I needed to enable a few extra flags to fix the template. Hope this helps. Cheers 👍