Weekly notes Navigation using Templater

What I’m trying to do

I want to replicate the logic from having a Prev | Next navigation from this Daily template, and applied the same concept on my Weekly template.

Things I have tried

This works for the Daily template :slight_smile:

CODE:

⬅️ [[<% moment(tp.file.title, "YYYY-MM-DD").subtract(1, "days").format("YYYY-MM-DD") %>]] | [[<% moment(tp.file.title, "YYYY-MM-DD").add(1, "days").format("YYYY-MM-DD") %>]] ➡️

OUTPUT:

Now … for the weekly template I’ve been spend 1-2 hours on it but can’t see how to make it work. The output I’m looking for is:

:arrow_left: [[2023-W39]] | [[2023-W41]] :arrow_right:

So far I tried :

TAKE 1:

<% tp.date.now("gggg-[W]ww").add(1, "weeks").format("gggg-[W]ww") %>

<% tp.date.now("gggg-[W]ww").subtract(1, "weeks").format("gggg-[W]ww") %>

TAKE 2:

<% tp.date.now("gggg-[W]ww", -1) %>
<% tp.date.now("gggg-[W]ww", 1) %>

TAKE 3:

<< [[<% tp.date.now("YYYY") %>-W<% tp.date.now("WW") - -1%>]] | [[<% tp.date.now("YYYY") %>-W<% tp.date.now("WW") - -3 %>]] >>

I also asked chatgpt, but nope :-/

Thanks for you help :slight_smile:

1 Like

That’s crazy lol.

I asked chatgpt to fix typos for my previous message.
It found the anwser!

⬅️ [[<% moment(tp.file.title, "YYYY-[W]ww").subtract(1, "weeks").format("YYYY-[W]ww") %>]] | [[<% moment(tp.file.title, "YYYY-[W]ww").add(1, "weeks").format("YYYY-[W]ww") %>]] ➡️ 
1 Like

thank you, just what I had been looking for :slight_smile:
my slightly adjusted version has the current week in the middle:

[[<% moment(tp.file.title, “YYYY-[W]ww”).subtract(1, “weeks”).format(“YYYY-[W]ww”) %>]] ← <% moment(tp.file.title, “YYYY-[W]ww”).format(“YYYY-[W]ww”) %> → [[<% moment(tp.file.title, “YYYY-[W]ww”).add(1, “weeks”).format(“YYYY-[W]ww”) %>]]

To give me the start and end days of the week, I also added

<%moment(tp.file.title).startOf(‘isoWeek’).format(“MMM DD”) %> - <%moment(tp.file.title).endOf(‘isoWeek’).format(“MMM DD”) %>

from Danny Hatcher video | templates.
… that I forgot I bookmarked a while back.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.