I have coded my own solution, using a mix of templater and dataviewjs. This is how it looks (actual look customisable via css):
Every daily note contains that blue header, which shows in the center (bold) the date of that note (same than the one in the title, but including the weekday, which I find useful), and two previous dates to the left, and two next dates to the right (if available, in this case there is a single one). Those contents are dynamics, showing only the actual existing notes. In this example, the next existing note after 30 may is 03 jun. There is no notes for 31 may, 01 jun or 02 jun. But if you create any of those intermediary dates, the header will update automatically.
The dates are clickable and lead to the corresponding daily note.
How
Using templater, I define the following template for my daily notes:
```dataviewjs
await dv.view("Templates/views/DailyHeader", "00-Journal")
```
## Log
- <% tp.file.cursor(1) %>
The dataviewjs
block does the magic, via custom views.
The first argument for dv.view()
is the name of a folder which contains a custom view (more
on that later), in my case Templates/views/DailyHeader
(you can put it wherever you want). The second argument is the name of the folder where your daily notes are stored (00-Journal
in my case). That folder can contain a flat structure with single notes for each day, or (like in my case) have other subfolder structure, such as YEAR/Month/daily-note.md
. It works anyway.
Now, the interesting part, the custom view. You have to create the folder Templates/views/DailyHeader
(if you decide to put it in the same place than me), and in that folder create two files, named:
You have to do that but using your system file explorer and a suitable text editor (eg: Notepad++ or VSCode).
The contents of those files are:
view.js
const locale = "en"; // Set the locale for date formatting
const dateFormat = "dd LLL (ccc)"; // Define the date format , see Luxon docs
function dailyHeader(folder) {
const daily_notes = dv.pages('"' + folder + '"');
// Generate 'before' , 'today', and 'after' sections, as concatenated strings
const before = daily_notes
.where(p => p.file.day && p.file.day < dv.current().file.day)
.sort(p => p.file.day, "asc")
.slice(-2)
.map(p => dv.fileLink(p.file.name, false, p.file.day
.toFormat(dateFormat, { locale: locale })))
.join(" · ") || "No dates before";
const today = `<b class="currentdate">${dv.current().file.day
.toFormat(dateFormat, { locale: locale })}</b>`;
const after = daily_notes
.where(p => p.file.day && p.file.day > dv.current().file.day)
.sort(p => p.file.day, "asc")
.limit(2)
.map(p => dv.fileLink(p.file.name, false, p.file.day
.toFormat(dateFormat, { locale: locale })))
.join(" · ") || "No more dates";
// Mix the sections into a single string, using a dot as a separator
const content = `${before} · ${today} · ${after}`;
// Render the content as a div with a specific class, for stylingy
return dv.el("div", content, { cls: "daily-header" });
}
// Call the function
dailyHeader(input);
view.css
b.currentdate {
background-color: var(--color-highlight);
color: var(--color-accent);
font-size: 1.2em;
padding: 3pt;
border-radius: 5pt;
}
.daily-header {
text-align: center;
margin-bottom: 1em;
padding-bottom: 1ex;
border-bottom: 1px solid var(--color-accent);
}
Customizations
You can change the first line of view.js
if you use a different locale. It will affect the name of the weekday and month. You can also adjust the dateFormat
variable to your taste (see Luxon Date Formatting)
You can change the css to customize the look of the “current date” and the whole header.