liamcain / obsidian-calendar-plugin

Simple calendar widget for Obsidian.
MIT License
1.57k stars 131 forks source link

Notes updated/ created on this day #228

Open petruut opened 2 years ago

petruut commented 2 years ago

Would be great to be able to click on a day and have a list below of the notes Created and Updated during that day. You're already displaying the word count, which intuitively makes me want to click the day and explore those notes further.

Would this be possible?

padowi commented 2 months ago

@petruut : If you are willing to use dataviewjs in your vault, and add a "date" field to your frontmatter in your daily notes template, you could use something like

const thisDay = moment(dv.current().date.toISODate()).startOf('day');
dv.paragraph(`${thisDay} ${dv.current().file.link}`);
let createdOrModifiedOnThisDay = dv.pages()
    .where(p => {
        let tempCdate = moment(p.file.cday.toISODate()).startOf('day');
        let tempMdate = moment(p.file.mday.toISODate()).startOf('day');
        if (tempCdate.year() !== thisDay.year() && tempMdate.year() !== thisDay.year()) { return false; }
        if (tempCdate.month() !== thisDay.month() && tempMdate.month() !== thisDay.month()) { return false; }
        if (tempCdate.date() !== thisDay.date() && tempMdate.date() !== thisDay.date()) { return false; }
        return true;
    })

createdOrModifiedOnThisDay.forEach(p => {
    dv.paragraph(`- ${p.file.link}`);
})

to emulate this (forgive me for the really shitty code, it is not my best work, it may contain some edge-case I haven't thought of, but for the most part it should work, or at least give you a hint about what you can do)

So if you add this into your daily notes template, every note will display what other files were created or modified on that date (but inside the daily note itself)