// Customise these
var monthOffset = 0 // how much to offset the month of headers, 0 is current month
var header = "h" // include a toc? "y"es "h"idden or no (any input), no header is default
//Don't edit below this point
var thisMonth = new Date().getMonth()
var thisYear = new Date().getFullYear()
function getWeekdayFromDate(date) {
const dayOfWeek = new Date(date).getDay();
return isNaN(dayOfWeek) ? null :
['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][dayOfWeek];
}
function getDaysInMonth(month, year) {
return new Date(year, month+1, 0).getDate();
}
var output = ""
if (header == "y") {
output = output.concat("${toc}\n\n* * *\n* * *\n\n")
} else if (header == "h") {
output = output.concat("<details><summary>TOC</summary>\n\n${toc}\n\n</details>\n\n* * *\n* * *\n\n")
}
daysInMonth = Array.from(Array(getDaysInMonth(thisMonth+monthOffset, thisYear)).keys())
for (var i in daysInMonth) {
var day = parseInt(i)+1
var date = new Date(thisYear, thisMonth+monthOffset, day)
output = output.concat("# ", day.toString().padStart(2, "0"), " ", getWeekdayFromDate(date), "\n\n\n")
}
return output
-
-
Save ImperialSquid/6be4aefa51a7ace58851779cc77350db to your computer and use it in GitHub Desktop.
The markdown needed to generate journal headers in Joplin using the JavaScript plugin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment