Now i’m stuck in the problem to increment and decrement the index variable simply by clicking on the [<<-] and [->>] that in my exaple are only placeholder.
After a lot of thinking and used ChatGPT to write javascript I’ve found a simple and I hope clean solution. A simple query in a template!
---
description: "Add link to previous and successive day."
tags:
- template
hooks.top:
where: 'name =~ /^Diario\//'
order: 100
---
{{#let @t = @page.name}}
{{#each {page where name =~ /^Diario\// and name < @page.name select name limit 1 order by name desc}}}◀ [[{{name}}]]{{/each}}🔳{{#each {page where name =~ /^Diario\// and name > @page.name select name limit 1 order by name asc}}}
[[{{name}}]] ▶
{{/each}}
{{/let}}
Please feel free to improve the query!
SilverBullet is awesome! I must think simple!
Thanks, very useful!
However, I don’t want to be niggling…
You declare the variable, bot don’t use it later on. So we could get rid of the “let-block”
The code could be shortened (and at least for me it is a bit more easy to understand) as:
{{#each {page where name =~ /^Diario\// and name < @page.name select name limit 1 order by name desc}}}◀ [[{{name}}]]{{/each}}🔳{{#each {page where name =~ /^Diario\// and name > @page.name select name limit 1 order by name asc}}}
[[{{name}}]] ▶
{{/each}}
Thanks! A lot of fiddling with the code left the variable I used to inspect what I wa doing! And when I dound the solution I was so extited to forgot to clean the code.