1
0

Docs and template sets work

This commit is contained in:
Zef Hemel 2023-12-22 16:40:38 +01:00
parent 3350c7f076
commit 0a7fc05fef
25 changed files with 99 additions and 54 deletions

View File

@ -51,7 +51,7 @@ export async function pageComplete(completeEvent: CompleteEvent) {
apply: isInTemplateContext
? pageMeta.name
: `${pageMeta.name}|${pageMeta.displayName}`,
detail: `displayName: ${pageMeta.name}`,
detail: `displayName for: ${pageMeta.name}`,
type: "page",
});
}
@ -63,7 +63,7 @@ export async function pageComplete(completeEvent: CompleteEvent) {
apply: isInTemplateContext
? pageMeta.name
: `${pageMeta.name}|${alias}`,
detail: `alias: ${pageMeta.name}`,
detail: `alias to: ${pageMeta.name}`,
type: "page",
});
}

View File

@ -52,7 +52,7 @@ export async function templateSlashComplete(
): Promise<SlashCompletion[]> {
const allTemplates = await queryObjects<TemplateObject>("template", {
// Only return templates that have a trigger
filter: ["!=", ["attr", "trigger"], ["null"]],
filter: ["attr", "trigger"],
});
return allTemplates.map((template) => ({
label: template.trigger!,

View File

@ -79,7 +79,7 @@ release.
* The {[Directive: Convert to Live Query/Template]} now also converts `#use` and `#include` directives
* Styling improvements for Linked Mentions
* SilverBullet now fully works when added as PWA on Safari 17 (via the “Add to Dock” option).
* Fix support for handlebars variables in [[Live Queries]] and [[live]]
* Fix support for handlebars variables in [[Live Queries]] and [[Live Templates]]
* Plug robustness improvements (SB shouldnt fully break when loading plugs that rely on disabled syscalls)
* Various other bug fixes

View File

@ -1,10 +1,10 @@
Federation enables _browsing_, and _synchronizing_ (parts of) spaces outside of the users space into your SilverBullet client.
Federation enables _browsing_, and _synchronizing_ (parts of) spaces _outside_ the users space into your SilverBullet client.
This enables a few things:
* Linking and browsing publicly hosted SilverBullet spaces (or websites adhering to its [[API]]). For instance the [[!silverbullet.md/CHANGELOG|SilverBullet CHANGELOG]] without leaving the comfort of your own SilverBullet client.
* Reusing content from externally hosted sources, such as:
* _Templates_, e.g. by federating with `silverbullet.md/template` will give you access to the example templates hosted there without manually copying and pasting them and automatically pull in the latest version. So you can, for instance, use `render [[!silverbullet.md/template/page]]` to use the [[template/page]] template.
* **Linking and browsing** to other publicly hosted SilverBullet spaces (or websites adhering to its [[API]]). For instance the [[!silverbullet.md/CHANGELOG|SilverBullet CHANGELOG]] without leaving the comfort of your own SilverBullet client.
* **Reusing** content from externally hosted sources, such as:
* _Templates_, e.g. by federating with `silverbullet.md/template` will give you access to the example templates hosted there without manually copying and pasting them and automatically pull in the latest version. So you can, for instance, use `render [[!silverbullet.md/template/page]]` to use the [[template/page]] template. See [[Template Sets]] for more on this use case.
* _Data_: such as tasks, item, data hosted elsewhere that you want to query from your own space.
**Note:** Federation does not support authentication yet, so all federated spaces need to be unauthenticated and will be _read-only_.

View File

@ -1,4 +1,4 @@
This page lists some potentially useful keyboard shortcuts. Also have a look at [[Manual/Outlines]] for outline specific keyboard shortcuts.
This page lists some potentially useful keyboard shortcuts. Also have a look at [[Outlines]] for outline specific keyboard shortcuts.
# Highlights
Particularly useful keyboard shortcuts (that you may not know about).
@ -17,7 +17,7 @@ Particularly useful keyboard shortcuts (that you may not know about).
|----------|----------|
| Cmd-/ / Ctrl-/ | Run command |
| Cmd-k/Ctrl-k | Open page |
| Cmd-Shift-p/Ctrl-Shift-p | Update plugs (from the [[PLUGS]] file) |
| Cmd-Shift-p/Ctrl-Shift-p | Update plugs (from the `PLUGS` file) |
| Alt-q | Refresh all live queries and templates on this page |
| Cmd-p/Ctrl-p | Toggle markdown preview |
| Ctrl-Alt-t | Toggle table of contents|

View File

@ -53,14 +53,13 @@ The main ways to roam your space, beside following page links, are:
* [[Linked Mentions]]
* [[Full Text Search]]
# End-User Programming
[[End-User Programming]] functionality allows you to be creative with the content you have in your space.
# Advanced topics
* [[Objects]]
* [[Frontmatter]]
* [[Attributes]]
* [[Templates]]
* [[Live Queries]]
* [[Live Templates]]
* [[Templates]] and [[Live Templates]]
* [[Federation]]: it possibly to “sync in” content from outside sources, such as [[Template Sets]]
# Extending SilverBullet
A lot of SilverBullets functionality is built as [[Plugs]] using the robust [[PlugOS]] extension mechanism. If you are adventurous you can try to build [[Plugs/Development|such plugs yourself]].

View File

@ -1,6 +1,6 @@
Code widgets are a SilverBullet-specific “extension” to [[Markdown]]. Technically, its not an extension — it just gives new meaning to markdowns native fenced code blocks — code blocks that start with a triple backtick, specifying a programming language.
Currently, SilverBullet provides two code widgets as part of its built-in [[🔌 Plugs]]:
Currently, SilverBullet provides two code widgets as part of its built-in [[Plugs]]:
* `embed`
* `markdown`

View File

@ -15,13 +15,13 @@ Every object has a set of [[Attributes]].
At the very least:
* `ref`: a unique _identifier_ (unique to the page, at least), often represented as a pointer to the place (page, position) in your space where the object is defined. For instance, a _page_ object will use the page name as its `ref` attribute, and a `task` will use `page@pos` (where `pos` is the location the task appears in `page`).
* `tags`: an array of type(s) of an object, see [[@tags]].
* `tags`: an array of type(s) of an object, see [[$tags]].
In addition, any number of additional tag-specific and custom [[Attributes]] can be defined (see below).
# Tags
$tags
Every object has one or more tags, defining the types of an object. Some tags are built-in (as described below), but you can easily define new tags by simply using the #hashtag notation in strategic locations (more on these locations later).
Every object has one or more tags, defining the _types_ of an object. Some tags are built-in (as described below), but you can easily define new tags by simply using the #hashtag notation in strategic locations (more on these locations later).
Here are the currently built-in tags:
@ -48,7 +48,7 @@ The following query shows all attributes available for tasks:
```query
upnext
```
Although you may want to render it using a template such as [[template/tasks/task] instead:
Although you may want to render it using a template such as [[template/task]] instead:
```query
upnext render [[template/task]]
@ -68,10 +68,10 @@ taskstate where page = "{{@page.name}}"
## template
$template
Indexes all pages tagged with `#template`. Technically this is not a built-in, but well list it here anyway. See [[Templates]] for more information on templates.
Indexes all pages tagged with `#template`. See [[Templates]] for more information on templates.
```query
template
template select name
```
@ -149,7 +149,7 @@ The ultimate meta tag is _tag_ itself, which indexes for all tags used, in which
Here are the tags used/defined in this page:
```query
tag where page = "{{@page.name}}"
tag where page = "{{@page.name}}" select name, parent
```
## attribute

View File

@ -8,5 +8,5 @@ A space consists of
* [[Attachments]]
# Folder lay-out
Every space in SilverBullet at the very least has an index page (by default named `index.md`) and a [[SETTINGS]] page (named `SETTINGS.md`). If you install custom [[🔌 Plugs]], these will be kept under `_plug` in your spaces folder.
Every space in SilverBullet at the very least has an index page (by default named `index.md`) and a [[SETTINGS]] page (named `SETTINGS.md`). If you install custom [[Plugs]], these will be kept under `_plug` in your spaces folder.

View File

@ -5,5 +5,5 @@ All special pages except [[SETTINGS]] are optional: if they dont exist, well,
Here are the current list of “special pages” known to humankind:
* [[SETTINGS]] for setting various settings
* [[PLUGS]] as a source for the plug manager to decide what plugs to load and where from
* `PLUGS` as a source for the plug manager to decide what plugs to load and where from
* [[VIMRC]] for tweaking [[Vim]] mode

View File

@ -1,4 +1,4 @@
The SilverBullet CLI has a `sync` command that can be used to synchronize local as well as remote [[Space|spaces]]. This can be useful when migrating between different [[Install/Configuration$storage|storage implementations]]. It can also be used to back up content elsewhere. Under the hood, this sync mechanism uses the exact same sync engine used for the Sync [[Client Modes]].
The SilverBullet CLI has a `sync` command that can be used to synchronize local as well as remote [[Spaces]]. This can be useful when migrating between different [[Install/Configuration$storage|storage implementations]]. It can also be used to back up content elsewhere. Under the hood, this sync mechanism uses the exact same sync engine used for the Sync [[Client Modes]].
# Use cases
* **Migration**: you hosted SilverBullet on your local device until now, but have since set up an instance via [[Install/Deno Deploy]] and want to migrate your content there.

View File

@ -15,32 +15,42 @@ federate:
If you dont want to sync _all_ these templates, you can use more specific URIs, e.g.
```yaml
federate:
- uri: silverbullet.md/template/task
- uri: silverbullet.md/template/page/
```
to just get the `task` stuff.
to just get the page templates, for instance.
To reference a template, use the federation syntax, e.g. `[[!silverbullet.md/template/task]]`.
To reference a template, use the [[Federation]] syntax, e.g. `[[!silverbullet.md/template/task]]`.
# Page Templates
Use these [[Page Templates]] with the {[Page: From Template]} command.
## Maintenance
```query
template where name =~ /^template\/maintenance/
order by order
render [[template/documented-template]]
template where type = "page" render [[template/documented-template]]
```
## Pages
# Slash Templates
These can be used as [[Slash Templates]]:
```query
template where type = "slash" render [[template/documented-template]]
```
# Live Templates
Use these as `page` in [[Live Templates]].
```query
template
where name =~ /^template\/pages/
where type = "live"
order by order
render [[template/documented-template]]
```
## Tasks
# Live Query
Use these in your `render` clauses in [[Live Queries]].
```query
template where name =~ /^template\/task/
template
where type = "query"
order by order
render [[template/documented-template]]
```
## Debugging
```query
template where name =~ /^template\/debug/ render [[template/documented-template]]
```

View File

@ -1,5 +1,14 @@
#template
---
tags: template
type: query
order: 100
description: |
Renders its object value in a `key: value` format
usage: |
Can be used by passing in a YAML object in a template via `value` or in a `render` clause of a query
---
{{#each .}}
{{@key}}: {{.}}
{{/each}}
---

View File

@ -1,12 +0,0 @@
---
tags: template
description: |
Renders its object value in a `key: value` format
usage: |
Can be used by passing in a YAML object in a template via `value` or in a `render` clause of a query
---
{{#each .}}
{{@key}}: {{.}}
{{/each}}
---

View File

@ -1,4 +1,5 @@
* [[{{ref}}|{{ref}}]] {{description}}
#template
* [[{{ref}}|{{#if displayName}}{{displayName}}{{else}}{{ref}}{{/if}}]] {{description}}
{{#if usage}}
* **Usage:** {{usage}}
{{/if}}

View File

@ -1,5 +1,6 @@
---
tags: template
type: live
description: Lists all pages with ".conflicted" in the name, created as a result of a synchronization conflict.
---

View File

@ -1,5 +1,6 @@
---
tags: template
type: live
description: |
Shows all tasks that reference (tag) the current page. For instance a task that references `[[John]]` in its name, would appear on the `John` page if it would use this [[sets/tasks/incoming]] template.
order: 2

View File

@ -1,5 +1,6 @@
---
tags: template
type: live
description: Queries all tasks tagged with a specific tag.
usage: Pass in the tag to filter on as the `value` of this template
order: 2

View File

@ -1 +1,8 @@
---
tags: template
type: query
order: 1
description: A page reference link as a list item
---
* [[{{name}}]]

View File

@ -3,6 +3,7 @@ tags: template
type: page
displayName: Slash Template
pageName: "template/slash/"
description: Define a new Slash Template
frontmatter:
tags: template
trigger: "|^|"

View File

@ -3,8 +3,9 @@ tags: template
type: page
displayName: Page Template
pageName: "template/page/"
description: Define a new Page Template
frontmatter:
tags: template
displayName: "|^|"
type: page
---
|^|

View File

@ -0,0 +1,9 @@
---
tags: template
type: slash
trigger: "note-admonition"
displayName: "/note-admonition"
description: Insert a "note" admonition
---
> **note** Note
> |^|

View File

@ -0,0 +1,7 @@
---
tags: template
trigger: "table"
---
| Header A | Header B |
|----------|----------|
| |^| | Cell B |

View File

@ -0,0 +1,9 @@
---
tags: template
type: slash
trigger: "warning-admonition"
displayName: "/warning-admonition"
description: Insert a "warning" admonition
---
> **warning** Warning
> |^|

View File

@ -1,5 +1,6 @@
---
tags: template
type: query
description: generic task template that supports updating the status back in the origin page
order: 1
---