Action

Open Daily Note

Posted by agiletortoise, Last update about 2 hours ago

Open or create a daily note. Configure variables at the beginning of the script to change format of the daily note title and initial template and tag.

By default, this creates notes with the title line # YYYY-MM-DD Daily and the tag daily assigned. If you run this action and there already exists a matching title, it will open the draft in the editor. If the note for today’s date does not yet exist, it will create it and open it.

Steps

  • script

    // set up template
    let dailyNoteTag = "daily"
    let dateTag = "[[date|%Y-%m-%d]]"
    let title = `# ${draft.processTemplate(dateTag)} Daily`
    let template = `${title}
    
    `
    
    let drafts = Draft.query(`title:${title}`, "all", [dailyNoteTag])
    if(drafts.length > 0) { // found draft, open it
    	editor.load(drafts[0])
    }
    else { // no daily note yet, create it
    	let d = new Draft()
    	d.addTag(dailyNoteTag)
    	d.content = template
    	d.update()
    	editor.load(d)
    }
    
    // focus editor
    editor.activate()
    

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.