Skip to content

Instantly share code, notes, and snippets.

@basilioss
Last active September 12, 2024 02:18
Show Gist options
  • Save basilioss/b0d1e608781d0457004debccf213163b to your computer and use it in GitHub Desktop.
Save basilioss/b0d1e608781d0457004debccf213163b to your computer and use it in GitHub Desktop.
Obsidian template to rollover incomplete todo items from the previous daily note
<%*
// 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)
%>
@basilioss
Copy link
Author

I use Minimal theme

@Sean-Shmulevich
Copy link

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