silverbulletmd / silverbullet

The hackable notebook
https://silverbullet.md
MIT License
2.04k stars 141 forks source link

How do tasks with custom states and due dates work? #807

Open blandir opened 3 months ago

blandir commented 3 months ago

I'm trying to use tasks with custom states and set a due date. However, I cannot figure out what I have to do. I found https://silverbullet.md/Plugs/Tasks but there is no information where to configure the possible task states or how to insert the due date. There is no hint on the SETTINGS page as well.

Could somebody please tell me, where I can find such information?

simone-viozzi commented 3 months ago

I can't help with custom states, but I'm curious.

For Due Dates: To add a due date to a task, you can either use the attributes syntax or an emoji date format.

  1. Using Attributes Syntax: [due: YYYY-MM-DD]

    - [ ] Submit the final report [due: 2024-03-21]

    example queries:

    task where due = "2024-02-29"
    task where due <= "2024-02-29"
    task where due = null
  2. Using Emoji Dates: For a more visual method, include a calendar emoji followed by the date.

    - [ ] Review project milestones 📅 2024-02-29

    example queries:

    task where deadline = "2024-02-29"
    task where deadline <= "2024-02-29"
    task where deadline = null

To simplify the writing of due dates, I also created templates for due today, due tomorrow, due next week etc...

Due today template:

---
tags: template
description: "Due today"
hooks.snippet.slashCommand: dueToday
---
[due: {{today}}]

Due next week template

---
tags: template
description: "Due in a week"
hooks.snippet.slashCommand: dueWeek
---
[due: {{dateAdd(today, 7, "days")}}]

this required the creation of a space script to add the dateAdd function:

silverbullet.registerFunction("dateAdd", (baseDate, daysToAdd) => {
  const parsedBaseDate = Temporal.PlainDate.from(baseDate);
  const resultDate = parsedBaseDate.add({ days: daysToAdd });
  return resultDate.toString();
});