How can I get a prompt for text, append it as a link in today's daily note, then create a page with that as the title?

I want to make a command that does the following:

  • 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 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 [] 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 ="YYYY-MM-DD MMMM Do YYYY dddd")
let dailyNote = await checkPage(todaysDate)
let taskLink = `![[${task}]]`
let noteContent = await
// 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)
// This just checks if the link was successfully added to the daily note and then shows a notification for it.
if ((await { new Notice(`The task has been added to ${todaysDate}.`) }

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.