From d0ed24aae57db2e22a8203c5d288b8fa9238599e Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Wed, 21 Aug 2024 21:30:29 +0200 Subject: [PATCH] Docs --- plugs/index/item.ts | 8 +++++++- website/CHANGELOG.md | 3 ++- website/Objects.md | 43 +++++++++++++++++++++++++++---------------- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/plugs/index/item.ts b/plugs/index/item.ts index e34f93ba..97a426a3 100644 --- a/plugs/index/item.ts +++ b/plugs/index/item.ts @@ -34,7 +34,7 @@ export type ItemObject = ObjectValue< export async function indexItems({ name, tree }: IndexTreeEvent) { const items = await extractItems(name, tree); - console.log("Found", items, "item(s)"); + // console.log("Found", items, "item(s)"); await indexObjects(name, items); } @@ -53,6 +53,12 @@ export async function extractItems(name: string, tree: ParseTree) { return true; } + // Is this a task? + if (n.children.find((n) => n.type === "Task")) { + // Skip tasks + return true; + } + const item: ItemObject = await extractItemFromNode( name, n, diff --git a/website/CHANGELOG.md b/website/CHANGELOG.md index abf8f8cd..b2bd5303 100644 --- a/website/CHANGELOG.md +++ b/website/CHANGELOG.md @@ -5,7 +5,8 @@ An attempt at documenting the changes/new features introduced in each release. ## Edge _These features are not yet properly released, you need to use [the edge builds](https://community.silverbullet.md/t/living-on-the-edge-builds/27) to try them._ -* Nothing new since 0.9.1 +* Slashes in page names are no no longer URL encoded (in the URL) +* `task` and `item` [[Objects]] now have a `parent` attribute when nested, and inherit their ancestors’ tags in `itags` — see [[Objects#item]] for an example. ## 0.9.1 * Widget buttons for [[Transclusions]] (by [onespaceman](https://github.com/silverbulletmd/silverbullet/pull/1013)) as well as some other transclusion-related fixes diff --git a/website/Objects.md b/website/Objects.md index 0df4dc66..2b5c935c 100644 --- a/website/Objects.md +++ b/website/Objects.md @@ -55,9 +55,31 @@ table Table headers will be normalized by converting them to lowercase and replacing all non alphanumeric characters with `_`. -## task +## item +List items (both bullet point and numbered items) are indexed with the `item` tag, and additional tags can be added using [[Tags]]. -task +Here is an example of a #quote item using a custom [[Attributes|attribute]]: + +* “If you don’t know where you’re going you may not get there.” [by: Yogi Berra] #quote + +And then queried via the #quote tag: + +```query +quote where page = @page.name and tag = "item" select name, by +``` + +When items are nested, they will contain a `parent` attrite with a reference to their parent. In addition, `itags` will also inherit their ancestors’ tags. For instance: + +* Root item #root-tag + * Sub item #sub-tag + * Leaf item + +The `Leaf item` will be indexed as follows: +```query +item where page = @page.name and name = "Leaf item" select name, parent, itags +``` + +## task Every task in your space is tagged with the `task` tag by default. You tag it with additional tags by using [[Tags]] in the task name, e.g. * [ ] My task #upnext @@ -76,6 +98,9 @@ Although you may want to render it using a template such as [[Library/Core/Query upnext render [[Library/Core/Query/Task]] ``` +Similar to [[#item]], `task` objects have a `parent` attribute when nested (pointing to their parent `item`), and inherit their ancestor’s tags in `itags`. + + ## taskstate [[Plugs/Tasks]] support the default `x` and ` ` states (done and not done), but custom states as well. Custom states used across your space are kept in `taskstate`: @@ -95,20 +120,6 @@ Indexes all pages tagged with `#template`. See [[Templates]] for more informatio template select name limit 5 ``` - -## item -List items (both bullet point and numbered items) are indexed with the `item` tag, and additional tags can be added using [[Tags]]. - -Here is an example of a #quote item using a custom [[Attributes|attribute]]: - -* “If you don’t know where you’re going you may not get there.” [by: Yogi Berra] #quote - -And then queried via the #quote tag: - -```query -quote where page = @page.name and tag = "item" select name, by -``` - ## paragraph Top-level paragraphs (that is: paragraphs not embedded in a list) are indexed using the `paragraph` tag, any additional tags can be added using [[Tags]].