Hi there, I’m new to SilverBullet and am looking to use it for D&D player notes.
I have a page for my campaign, and am trying to create a command to automatically instantiate a Location template at a path relative to my campaign page. The idea is that a “New Location” button will be clicked on the campaign page which will run the command.
Here’s my current command:
silverbullet.registerCommand({name: "New D&D Campaign Location", hide: false}, async () => {
const name = await editor.getCurrentPage()
const tmpl = await space.readPage("Custom/Templates/Location")
const rendered = await template.renderTemplate(tmpl, {}, { page: tempPageMeta, config })
const path = `${name}/Locations/New Location`
await space.writePage(path, rendered)
editor.navigate(path)
})
When I run this command, the page is created in the correct location, but the template frontmatter is not transformed and is instead placed in full. Example:
---
tags:
- template
frontmatter:
tags:
- location
dateCreated: "2024-09-18"
---
# Location
Test Location
This is my template:
---
tags:
- template
frontmatter:
tags:
- location
dateCreated: "{{today}}"
---
# Location
Test Location
I feel as though the way I’m (trying) to do this is very hacky. If anyone has any suggestions, I’d love to hear them.
Thanks