I’m trying to configure this pagination feature from a template I found on GitHub and it doesn’t seem to be working for me. After inserting it into a template, and then creating a note from that template, it all just disappears. Also using Replace template in the active file produces the same results.
I’ve tried playing around with the script, but I’m terrible with Javascript and getting nowhere. I ended up just using Templater to create a simple pagination for my daily and weekly notes, but I’d like to get something like this working.
I suspect it’s me just not formatting my dates right.
Here are my daily and weekly formats:
Daily:
YYYY/MMM/[W]-ww/dddd-MMM-DD-YY
Weekly:
YYYY/MMM/[W]-ww/YYYY-[W]-ww
There’s both in /Daily.
I also haven’t set up Monthly, Quarterly, or yearly note yet.
Most of the whole snippet you shared is actually commented out (99% of the lines start with // … which is how you add line comment in JS) …
So, unless something happened when you copied/pasted it here, it could explain why it doesn’t work …
This seems to work though :
<%*
// Get today's date from the daily note's title
// Daily note title format is "dddd-MMM-DD-YY"
const today = moment(tp.file.title, "dddd-MMM-DD-YY");
// Format today as "YYYY/MM/DD - dddd"
const heading = moment(today).format("YYYY/MM/DD - dddd");
// Format today as "YYYY" (for the link to the year)
const yearLink = moment(today).format("YYYY");
// Format today as "YYYY[-Q]Q[|Q]Q" (for the link to the quarter)
const quarterLink = moment(today).format("YYYY[-Q]Q[|Q]Q");
// Format today as "YYYY-MM[|]MMMM" (for the link to the month)
const monthLink = moment(today).format("YYYY-MM[|]MMMM");
// Format today as "gggg[-W-]ww[|Week ]w" (for the link to the week)
const weekLink = moment(today).format("gggg[-W-]ww[|Week ]w");
// Get "yesterday" and format it as "dddd-MMM-DD-YY[|]YYYY-MM-DD"
const yesterdayLink = moment(today).subtract(1, 'd').format("dddd-MMM-DD-YY[|]YYYY-MM-DD");
// Format today as "YYYY-MM-DD"
const todayNav = moment(today).format("YYYY-MM-DD");
// Get "tomorrow" and format it as "dddd-MMM-DD-YY[|]YYYY-MM-DD"
const tomorrowLink = moment(today).add(1, 'd').format("dddd-MMM-DD-YY[|]YYYY-MM-DD");
-%>
# <% heading %>
[[<% yearLink %>]] / [[<% quarterLink %>]] / [[<% monthLink %>]] / [[<% weekLink %>]]
❮ [[<% yesterdayLink %>]] | <% todayNav %> | [[<% tomorrowLink %>]] ❯
Note: the snippet, to work properly, needs to be applied to note titled following the format you chose for your daily note’s title … as the title is used in the snippet to determine when “today” is and format its date in various ways
So, the snippet applied to a note titled Saturday-October-26-24 output: