Dataview - Display Embedded notes from first '#' & include link to note?

What I’m trying to do

I am trying to embed the contents of a simplified Daily Note into a single page. The goal here is have a running log of the notes I make in daily notes over the past 7 days.

I would like to include only the portion of each daily note from the first ‘#’ block and then have a link back to each note near each note’s embedded content (so I can jump back there if needed).

(I know there are some plugins that can concatenate notes like this, but I’m hoping to have this as a Dataview block, so I can place it into other pages with some different criteria. I don’t want a plugin that makes it all appear on its own page.)

Things I have tried

I have this bit of dataviewjs that works very closely to what I want:

const now = moment(); 
const last7Days = now.subtract(7, 'days');

const pages = dv.pages('"01-Daily Notes"').where(p => p.tag.includes("daily-note") && moment(p.created).isAfter(last7Days)).sort(p => moment(p.file.name), 'desc');

console.log(pages);

pages.forEach(page => {dv.el("p","![[" + page.file.link.path + "]]")});

And this is the daily note template I’m using:

created: <% tp.file.creation_date() %>
tag: daily-note
title: "<% moment(tp.file.title,'YYYY-MM-DD').format("dddd, DD MMMM YYYY") %>"
---
# <% moment(tp.file.title,'YYYY-MM-DD').format("dddd, DD MMMM YYYY") %>

This is the output I get from the above dataviewjs:

QUESTIONS

  1. Is there a way to embed these notes starting at the first # heading even though the text after the # changes for each note?
  2. How can I remove the centered date, just above the heading text version?
  3. How would you go about including a link to each of those notes?

Thanks for any input.

I’ve since answered my #2 question.

Use this CSS snippet to remove those titles:

.block-language-dataviewjs .markdown-embed-title {
	display: none;
}

Well, I guess posing it as a question here got my brain organized around how to solve this query. Here is my current solution:

DataviewJS block is now this:

const pages = dv.pages('"01-Daily Notes"') // all pages within the "01-Daily Notes" folder hierachy
    .where(p => p.tag.includes("daily-note")) // include only those notes that have the tag 'daily-note'
    .sort(p => moment(p.created), 'desc') // Sort by creation date in descending order
    .slice(0, 5); // Take the top 5 most recent pages - change to 10 for more

pages.forEach(page => {
    dv.el("p", "![[" + page.file.name + "]]"); // create the embedded note link for each of the returned pages, up to the number we slice at above
});

And then this is the Daily Note Templater template:

---
created: <% tp.file.creation_date() %>
tag: daily-note
title: "<% moment(tp.file.title,'YYYY-MM-DD').format("dddd, DD MMMM YYYY") %>"
---
# [[<% tp.file.creation_date("YYYY-MM-DD-dddd") %>|<% moment(tp.file.title,'YYYY-MM-DD').format("dddd, DD MMMM YYYY") %>]]

<% tp.file.cursor() %>

This will create a note that has a link back to itself in the first heading.

And add this CSS Snippet to remove the inline file name from the Dataview embedded note block (note - it does not hide that title from normal embeds - remove the .block-language-dataviewjs part to remove across whole vault):

.block-language-dataviewjs .markdown-embed-title {
	display: none;
}

I think that solves what I was looking to do.

Feel free to contribute any other ideas if you see ways to improve on this.

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