Shows a one-line text dialogue with a title saying “Task name”
It appends it to today’s daily note: ![[Tasks/Task Name]], creating a link to a page with that title inside the Tasks folder.
It creates a page with that title inside the Tasks folder and opens it in a new tab.
I spent a bunch of time looking stuff up to do this but couldn’t figure this out. I think this could be done either with a Templater script or QuickAdd macro.
I had asked Phind and Perplexity.ai how to solve this and they didn’t give good answers, so I gave one web search plugin for ChatGPT Plus: Webpilot a shot. I did a bunch of back and forth with it for JS snippets, giving it the link [https://docs.obsidian.md] to look through. I did a bunch of editing and made this Templater template, which I added a hotkey for:
// Check if the page passed in exists, if not then create it.
function checkPage(pageName) {
page = app.vault.getAbstractFileByPath(`${pageName}.md`)
return page ? page : app.vault.create(`${pageName}.md`, '')
}
let task = `Tasks/${await tp.system.prompt("Enter task:")}`
// You can enter in whatever the date format is for your daily notes.
let todaysDate = tp.date.now("YYYY-MM-DD MMMM Do YYYY dddd")
let dailyNote = await checkPage(todaysDate)
let taskLink = `![[${task}]]`
let noteContent = await app.vault.read(dailyNote)
// This if block checks if theres an H2 heading title "Tasks". If not then it adds it to the bottom. You can remove the whole if { } block if you want.
if (!noteContent.includes(heading = "## Tasks")) {
await app.vault.append(dailyNote, heading)
}
if (!noteContent.includes(taskLink)) {
await app.vault.append(dailyNote, `${noteContent.endsWith('\n')?'':'\n'}${taskLink}`)
} let taskFile = await checkPage(task)
app.workspace.activeLeaf.openFile(taskFile)
// This just checks if the link was successfully added to the daily note and then shows a notification for it.
if ((await app.vault.read(dailyNote)).includes(taskLink)) { new Notice(`The task has been added to ${todaysDate}.`) }