Suggestion to Rolodex Card index rolling

I’m playing with SilverBullet and I’m loving it.

Now I have a lot of info that ca be useful to browse in a Rolodex Card manner, so I have written this template:

{{#let @p = {page where tags = "Blog"}}}
{{#let @index = 8}}
[<<-] {{@index}} [->>]
name:   {{at(@p, @index).name}} 
title: {{at(@p, @index).title}} 
descr:  {{at(@p, @index).description}} 
event: {{at(@p, @index).event}} 
Tags:   {{at(@p, @index).tags}} 
{{/let}}
{{/let}}

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.

Can you give me a suggestion?

Thank!

Marco

This probably won’t work with just a template and needs a space-script.

Please can you give me hints how to write a space-scrpt to increment/decrement a variable?

Thank

Marco

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!

3 Likes

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}}

:slight_smile:

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.
:roll_eyes: