Silverbullet.md: Keeping Track of Lend Items
After using Obsidian for quite some time and cursing all Git plugins available for it, I am giving SilverBullet a try.
When buying a new gadget, I tend to collect notes in my wiki about it, on how to use it, tools, etc. But I also like to keep track of the items where they are, when I lend them to someone.
In both Obsidian, and now SilverBullet, I used the tag #borrowed
to keep track of which items are currently with other persons.
With an query
-codeblock I than listed all borrowed items on an overview page.
The solution with Obsidian was to add #borrowed John Doe
to the page of the gadget.
Which than could be queried with:
```query
#borrowed
```
SilverBullet provides a powerfull scripting and templating engine, which makes it highly extensible. So the approach was also quite similar, but was easier to make it much nicer looking.
Step 1 was creating the /lend
command, which adds a
```#borrowed
person: John Doe
when: "2025-01-21"
```
to the current page.
the date when it was lend to the person, is automatically filled with todays date.
The cursor to type the actual name is placed directly right of the person:
field.
This is achieved by adding a template with a slashCommand
-hook.
---
description: Lend an item
tags: template
hooks.snippet.slashCommand: lend
---
```#borrowed
person: |^|
when: "{{today}}"
```
This will add the /lend
command to your SilverBullet instance.
In step 2 we need a template to display the lend items on our overview page.
---
tags: template
description: List of items borrowed from you.
---
| Ref | Person | Date |
|-----|--------|------|
{{#each .}}
| [[{{page}}]] | {{person}} | {{when}} (for {{dateDiff(when,today())}} days) |
{{/each}}
I use a space-script
which provides the dateDiff()
function.
It can be found here.
Finally, the overview page itself, where all lend items are displayed in a table.
```
# Borrowed Items
```query
borrowed
select page, person, when
render all [[Local/template/indexborrowed]]
```
Adjust the template file location in render all [[…]]
and the result should look like this:
kthxbye!