Last active
September 12, 2024 02:18
-
-
Save basilioss/b0d1e608781d0457004debccf213163b to your computer and use it in GitHub Desktop.
Obsidian template to rollover incomplete todo items from the previous daily note
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
// v1.1: Fixed the error when inserting the template, when a note for the previous day does not exist | |
const previousDay = moment(tp.file.title, "YYYY-MM-DD").subtract(1, "days").format("YYYY-MM-DD") | |
const nextDay = moment(tp.file.title, "YYYY-MM-DD").add(1, "days").format("YYYY-MM-DD") | |
tR += "# " + tp.file.title + "\n" | |
%> | |
<< [[<% previousDay %>]] | [[<% nextDay %>]] >> | |
<%* | |
// Insert tasks from a previous day | |
try { | |
// Define checkboxes to move (https://minimal.guide/Block+types/Checklists) | |
const checkboxes = ["- [ ]", "- [/]", "- [>]"] | |
// Get array of tasks | |
const file = await tp.file.include("[[" + previousDay + "]]") | |
const array = file.split('\n') | |
const tasks = array.filter(a => checkboxes.some(c => a.includes(c))) | |
// [/], [>] => [ ] | |
for (i = 0; i < tasks.length; i++) | |
tR += tasks[i].replace(/\[\/\]/, '[ ]').replace(/\[>\]/, '[ ]') + "\n" | |
} catch (error) { | |
new Notice(error, 5000) | |
} | |
// Move file to "journal" folder | |
await tp.file.move('journal/'+tp.file.title) | |
%> |
@lordkekz That's much better, thanks for sharing!
How do you get the checkbox to display like the video?
I use Minimal theme
this is exactly what i was looking for <3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is really nice!
I made an adapted version that works as a user script, can look behind for previous daily notes in case a day is skipped, and is able to filter out tasks that match the format used by the day planner plugin.
What do you think?
rolloverTodo.js
In your daily note template:
For default behavior (up to 3 days skipped and with ignoring of day planner):
<% tp.user.rolloverTodo(tp) %>
For behavior like the original (0 skipped days and no filter for day planner):
<% tp.user.rolloverTodo(tp, 0, false) %>
Note that I removed the automatic file title and linking of yesterday/tomorrow, since I'm putting them somewhere else in my personal tempate.