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) | |
%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do you get the checkbox to display like the video?