I’m trying to add a feature into my Daily Notes which more or less quotes the journal entries from the same day of the last years into the new note.
I’ve already found a working code which I could alter a little bit to work as intended.
The only thing I couldn’t do is adding a sort function which reverses the order of the notes being displayed. Currently it’s from old to new (old on top) and I’d like to reverse it; but couldn’t find a solution.
The entries in the ‘Journal’ folder are: YYYY-MM-DD-Line
Here is the code:
const minYear = 2020;
const maxYear = 2100;
const journalPath = 'Review/Journal';
const rangeOfYears = (start, end) => Array(end - start + 1)
.fill(start)
.map((year, index) => year + index)
const d = new Date(dv.date(dv.current().file.name));
const currentYear = d.getFullYear();
const availableYears = rangeOfYears(minYear, maxYear);
const month = ("0" + (d.getMonth() + 1)).slice(-2);
const day = ("0" + (d.getDate())).slice(-2);
const dateString = month + '-' + day;
availableYears.forEach((y) => {
var note = dv.page(`${journalPath}/${y}-${dateString}-Line`);
if (note && y !== currentYear) {
dv.el('div', `![[${note.file.path}|${y}]]`);
}
});
I’m pretty new to this. So thanks for your help!