Virtual Page: Recent Journal Entries

This is really helpful thanks!

I have a level 2 header in each of my journal entries, and I'd like only to display the text that appears under the header. How would I do this? I've been playing around with space.readRef but can't get it to work.

My current code:

virtualPage.define {
  pattern = "Daily Scores",
  run = function()
    local text = "# Daily Scores\n\n"

    local dailyScores = query[[
      from index.tag "header"
      where name:match("Daily score")
      order by page desc
      limit 14
    ]]

    if #dailyScores == 0 then
      text = text .. "No scores found!\n"
    else
      for page in dailyScores do
          text = text .. "# [[" .. page.page .. "]]\n\n"

          -- Read and include page content
          -- WIP
          local content = space.readRef(page.ref)
          if content then
            text = text .. content .. "\n\n---\n\n"
        end
      end
    end

    return text
  end
}