From cc5c2ee31672e5be1d6713a3560482a3b46b80ee Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Fri, 13 Oct 2023 17:10:57 +0200 Subject: [PATCH] staskstate meta data --- plugs/index/builtins.ts | 7 +++++++ plugs/tasks/task.ts | 26 ++++++++++++-------------- website/Objects.md | 12 ++++++++++++ 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/plugs/index/builtins.ts b/plugs/index/builtins.ts index 7eaa750..1f217d9 100644 --- a/plugs/index/builtins.ts +++ b/plugs/index/builtins.ts @@ -25,6 +25,13 @@ export const builtins: Record> = { pos: "number", tags: "array", }, + taskstate: { + ref: "string", + tags: "array", + state: "string", + count: "number", + page: "string", + }, tag: { ref: "string", name: "string", diff --git a/plugs/tasks/task.ts b/plugs/tasks/task.ts index a2fac5c..83db5a6 100644 --- a/plugs/tasks/task.ts +++ b/plugs/tasks/task.ts @@ -20,24 +20,22 @@ import { rewritePageRefs } from "$sb/lib/resolve.ts"; import { ObjectValue } from "$sb/types.ts"; import { indexObjects, queryObjects } from "../index/plug_api.ts"; -export type TaskObject = { - ref: string; - tags: string[]; - page: string; - pos: number; - name: string; - done: boolean; - state: string; - deadline?: string; -} & Record; +export type TaskObject = ObjectValue< + { + page: string; + pos: number; + name: string; + done: boolean; + state: string; + deadline?: string; + } & Record +>; -export type TaskStateObject = { - ref: string; - tags: string[]; +export type TaskStateObject = ObjectValue<{ state: string; count: number; page: string; -}; +}>; function getDeadline(deadlineNode: ParseTree): string { return deadlineNode.children![0].text!.replace(/📅\s*/, ""); diff --git a/website/Objects.md b/website/Objects.md index 4ad2280..2586059 100644 --- a/website/Objects.md +++ b/website/Objects.md @@ -54,6 +54,18 @@ Although you may want to render it using a template such as [[template/task]] in upnext render [[template/task]] ``` +## taskstate +[[🔌 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`: + +* [NOT STARTED] Task 1 +* [IN PROGRESS] Task 2 + +And can be queried as follows: + +```query +taskstate where page = "{{@page.name}}" +``` + ## item $item List items (both bullet point and numbered items) are indexed by default with the `item` tag, and additional tags can be added using [[Tags]].