Hi Alan,
thanks again for your tipps.
Unfortunately, they aren’t working yet.
This is my actual code (which I have from you), which searches all of my files and works pretty good, but needs some time, to load (the ``` at the beginning and the end of the code are not shown):
dataviewjs
const header = '## What happend today\\?'
// You can update this to filter as you like - filtering for just your daily notes would be good
const pages = dv.pages().sort(x => x.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 && summary[1].trim()) {
// Output the header and summary
dv.header(2, file.basename)
dv.paragraph(summary[1].trim())
}
}
And here’s my code, with your first tipp included:
dataviewjs
const header = '#+ [^\n]*?what happened'
// You can update this to filter as you like - filtering for just your daily notes would be good
const pages = dv.pages().sort(x => x.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 && summary[1].trim()) {
// Output the header and summary
dv.header(2, file.basename)
dv.paragraph(summary[1].trim())
}
}
Result:
Unfortunately, it doesnt show anything…
And here’s my code, with your second tipp included:
dataviewjs
const header = '## What happend today\\?'
// You can update this to filter as you like - filtering for just your daily notes would be good
const pages = dv.pages('#daily').sort(x => x.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 && summary[1].trim()) {
// Output the header and summary
dv.header(2, file.basename)
dv.paragraph(summary[1].trim())
}
}
Same here, no result…
I assume, I inserted your additions at the wrong place, or did something else wrong?
Thanks in advance!
kind regards,
Silias