1
0
silverbullet/website/Live Frontmatter Templates.md
2024-01-04 20:11:07 +01:00

37 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Live Frontmatter Templates allow you to override the default rendering of [[Frontmatter]] at the top of your pages with a custom template.
> **warning** Warning
> This feature is still _experimental_, aspects of it may change, or it could be removed altogether.
If you have no idea what that means or what you would use this for; you probably dont need this feature. Dont worry about it.
# Defining
Live Frontmatter Templates follow the same pattern as other [[Templates]] with a few additional attributes:
* `tags`: should be set to `template` as for any other template
* `type`: should be set to `frontmatter`
* `where`: should contain an [[Live Queries$expression]] that evaluates to true for the _pages_ you would like to apply this Live Frontmatter Template to, usually this checks for a specific tag, but it can be any expression. Think of this as a `where` clause that should match for the pages this template is applied to.
* `priority` (optional): in case you have multiple Live Frontmatter Templates that have matching `where` expression, the one with the priority set to the lowest number wins.
# Example
The following Frontmatter Template applies to all pages tagged with `person` (see the `where`). It first lists all [[Frontmatter]] attributes, followed by a use of the [[!silverbullet.md/template/live/incoming]] template, showing all incomplete tasks that reference this particular page.
Indeed, you can use [[Live Queries]] and [[Live Templates]] here as well.
---
tags: template
type: frontmatter
where: 'tags = "person"'
---
{{#each .}}**{{@key}}**: {{.}}
{{/each}}
## Incoming tasks
```template
page: "[[!silverbullet.md/template/live/incoming]]"
```
## Plug frontmatter template
This site uses the [[internal-template/plug-frontmatter]] template for pages tagged with `plug`, such as [[Plugs/Editor]], [[Plugs/Github]] and [[Plugs/Mermaid]].