Summarize Daily Notes in DataView referencing file link

First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.

What I’m trying to do

I’m trying to get individual notes to automatically reference and pull in narrative content from my daily notes. Right now I’m using ‘# header’ as the reference, but I’d like to use the file link as the reference instead.

Things I have tried

Copied below is what I am using. I’m trying to switch to a file link, but don’t know how to reference this. Any help is great!

Shout out to AlanG for the original code.

const header = '# Pay Equity'



// You can update this to filter as you like - filtering for just your daily notes would be good
const pages = dv.pages()
	.sort(page => page.file.name, "desc")

// This regex will return text from the Summary header, until it reaches
// the next header, a horizontal line, or the end of the file
const regex = new RegExp(`\n${header}\r?\n(.*?)(\n#+ |\n---|$)`, 's')

for (const page of pages) {
    const file = app.vault.getAbstractFileByPath(page.file.path)
    // Read the file contents
    const contents = await app.vault.read(file)
    // Extract the summary via regex
    const summary = contents.match(regex)
    if (summary) {
        // Output the header and summary
        dv.header(1, page.file.link)
        dv.paragraph(summary[1].trim())
    }
}

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.