How to Process Daily Notes

Hi! I started using Obsidian for the same reasons and similarly ran into the same organizational vagueness as you.

The problem I ran into, was that often times I want to write a quick thought relevant to one of these areas, but I don’t want to break my flow and hop around too much. I don’t necessarily want to link directly to avoid overcrowding with connections that are useful.

To address this, I have a couple of heading “key words” that overlap with major areas in my life, that I have MOC notes for. (e.g., Career, Health). I write down random thoughts or details I might want to review later.

Then, on the MOC page, I have a handy dataview query that searches all of my daily notes and extracts the text under each heading into a “log” for that page, separated by the daily note title (i.e., the date). That way, I can review things when it makes sense and still have the context of when I wrote them, without having to duplicate daily logs everywhere.

Here is the query I use that a helpful forum member sent to me (sorry I don’t have the name offhand to give credit!)

Curious if anyone else uses this method? Any ways to improve upon it?

// Headings you would like to summarise the text for
const headings = ['Investing']

// You can update this to filter as you like.
// Here it is only returning results inside the "Daily notes" folder
const pages = dv.pages('"Daily notes"')

const output = {}
headings.forEach(x => output[x] = [])

for (const page of pages) {
  const file = app.vault.getAbstractFileByPath(page.file.path)
  // Read the file contents
  const contents = await app.vault.read(file)
  for (let heading of headings) {
    // Sanitise the provided heading to use in a regex
    heading = heading.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&')
    const regex = `(^|\n)#+ ${heading}\r?\n(.*?)(\n#+ |\n---|$)`
    // Extract the summary
    for (const block of contents.match(new RegExp(regex, 'isg')) || []) {
      const match = block.match(new RegExp(regex, 'is'))
      output[heading].push({
        title: file.basename,
        text: match[2].trim()
      })
    }
  }
}
Object.keys(output).forEach(heading => {
  dv.header(1, heading)
  output[heading].forEach(entry => {
    dv.header(4, entry.title)
    dv.paragraph(entry.text)
  })
})

PS - found the thread, shoutout again to @AlanG

4 Likes