Yet another variant on how to do this, which I’m incorporating into my vault right now is to use a combination of Templater and Modal forms. This allows me to select the date I want to create the entry for, and into which of my many journal like structures I want to insert it, and finally whether to use a date format for a daily, monthly or yearly note.
The modal form definition
This should be the one to import into the forms editor of Modal forms:
{
"title": "Journal date picker",
"name": "Journal date picker",
"customClassname": "journal_date_picker",
"fields": [
{
"name": "aDate",
"label": "The date of the journal",
"description": "",
"isRequired": true,
"input": {
"type": "date",
"hidden": false
}
},
{
"name": "baseFolder",
"label": "Base folder",
"description": "Fixed part of folder for journal entry",
"isRequired": false,
"input": {
"type": "select",
"source": "fixed",
"options": [
{
"value": "journal",
"label": "journal"
},
{
"value": "workJournal",
"label": "Work journal"
}
]
}
},
{
"name": "dateFormat",
"label": "Choose a date format",
"description": "Date format including variable folder parts",
"isRequired": false,
"input": {
"type": "select",
"source": "fixed",
"options": [
{
"value": "YYYY/MM/YYYY-MM-DD",
"label": "Daily - YYYY/MM/YYYY-MM-DD"
},
{
"value": "[Monthly/]YYYY-MM",
"label": "Monthly - Monthly/YYYY-MM"
},
{
"value": "[Yearly/]YearYYYY",
"label": "Yearly - Year/YYYY"
},
{
"value": "custom",
"label": "custom"
}
]
}
},
{
"name": "customDateFormat",
"label": "Custom date format",
"description": "Use moment.js format, i.e. YYYY-MM-DD",
"isRequired": false,
"condition": {
"dependencyName": "dateFormat",
"type": "isExactly",
"value": "custom"
},
"input": {
"type": "text",
"hidden": false
}
}
],
"version": "1"
}
My Templater template
And this is what I use to trigger the template, which will create the file if it doesn’t exist, and in any case return you a link to this file.
<%*
const modalForm = app.plugins.plugins.modalforms.api;
const result = await modalForm.openForm("Pick journal and date", { values: { aDate: tp.date.now("YYYY-MM-DD", 1) }});
let dateFmt = result.data.dateFormat == "custom"
? result.data.customDateFormat
: result.data.dateFormat
const variablePart = moment(result.data.aDate, "YYYY-MM-DD").format(dateFmt)
const filename = variablePart.includes("/")
? variablePart.split("/").slice(-1)
: variablePart
const fullfilepath = result.data.baseFolder + "/" + variablePart + ".md"
if ( !(await tp.file.exists(fullfilepath)) ) {
await tp.file.create_new("",
variablePart,
false,
app.vault.getAbstractFileByPath(result.data.baseFolder))
}
tR += "[[" + filename + "]]"
-%>
Typical input dialog could then look like:
