When I implemented tag pages (example), I realized: why would this need to be hardcoded in SilverBullet? Basically you can implement 90% of this using Page Templates you just don’t want those pages to actually be written to disk. They should just be… virtual.
Hence this idea of virtual pages. You’d define them much like page templates:
---
tags: template
hooks.virtualPage:
forPrefix: "📌 "
---
{{#let @tag = replace(@page.name, /^📌 /, "")}}
# {{@tag}}
These are all objects in your space tagged with #{{@tag}}.
## Pages
{{#each { page where tags = @tag } }}
...
{{/each}}
etc. etc.
{{/let}}
Whenever you’d hit a link to any page starting with the prefix (so 📌 in this case), you’d get a template rendered, read-only page.
I like this, because I can eliminate the current tag page implementation using it, but I’m sure there’s other use cases as well.
One open question here is if forPrefix is a good way to match pages, or it should support e.g. arbitrary page name patterns, e.g. using regexes?
Virtual pages would also be created on demand. So indeed, whenever you’d access a page starting with the forPrefix prefix, it’d be rendered using this virtual page template.
In another thread we discussed generating a weekly overview. You could reserve the Weekly Overview/ prefix for a virtual page template, which would based on whatever you put afterWeekly Overview/ would generate an overview for that particular week.
Rather than forPrefix:, you could use startsWith: to probably more closely match what is happening internally. You could additionally or alternatively have endsWith: to further narrow down the match. The presence of both would be AND’ed together.
There’s some other places that use forPrefix now, but I can deprecate that and suggest using startsWith instead. Seems like a better name, and naming things is hard.
This virtualPage hook is exactly what I’m looking for. Is it still on the roadmap @zef? If it’s off the roadmap, I’ll try to figure out some other ways of doing what I want
Trying to get an easy way to add virtual info-cards on my page. Like ![[🤖 servername]], which should render some info using the template and “servername” as page.name…