Display all sections that the heading link to the current note

What I’m trying to do

I have daily notes with a template that has an alias for a better human-readable date.

# 2023-05-16

---
aliases: [Tue May 16 (2023)]
---

Then in each project I have a logbook for my notes for each day which I reference to the daily notes.

# Project 1

## Logbook

### [[2023-05-16|Tue May 16 (2023)]]

I did something

What I want to do is to add to the template for the daily notes a dataview query that searches for all links on the headings and paste those heading on the daily note.

In other words, I want the daily notes to look like this.

# 2023-05-16

---
aliases: [Tue May 16 (2023)]
---

# Project 1

I did  something

# Project 2

I did something else

Things I have tried

I have no idea where to start.

Dataview is at its best when it can process metadata, aka lists, tasks and fields (both inline and frontmatter). It can process file contents, if you explicitly code for it, but it’s not where dataview excels, in my opinion. For more information related to this option, see Summarise text under headings (where AlanG shows some javascript code to extract text from given headings).

With that being said, if you changed to using lists for your log entries on progress, it would be a whole lot easier to write your query. Imagine the following list items (possibly spread across multiple files/projects):

(Within Project 1 file)

- [[2023-05-16|Tue May 16 (2023)]] I did something

(Within Project 2 file)
- [[2023-05-16|Tue May 16 (2023)]] I did something else

These should now be collectable using something like

```dataview
LIST regexreplace(item.text, "^\[\[.*?\]\]", "")
FLATTEN file.lists as item
WHERE contains(item.outlinks, [[]])
SORT file.name
```

Here the list output shows the project name, and I remove the link from the start of the list item, to only show the actual update text (with potentially any other links in there). Note that this expects the usage of [[wikilinks]] for the replace to work correctly.

1 Like

This is very cool, thanks for sharing. My only concern is that I don’t think that the daily discussion and tasks I develop for each project will fit into an item from a list. I noticed that I can have single line of a paragraph, but not multiple paragraphs with figures. I am looking more for a solution that do exactly the same thing but for sections initiated by a header.

You could use the import sections from headings which I linked to, but I’m make common from a different world of documenting where I feel that’s just to much.

However, if you’ve got longer section and figures and what not, maybe it could be an alternative to use tasks to summarise that section (and not list item). This will have the added benefit over a pure list item, that the task will provide a link back to the project.

This way you’ll get a succinct summary with a link back option in your daily notes, so that you’ll get a quick overview of what you achieved, whilst still have an easy access to the details.

If this sounds interesting, I could whip up an example depicting how this could be written.

1 Like

That sounds interesting, so you mean that in the project note it would be something like

# Project 1

## [[2023-05-16|Tue May 16 (2023)]]

- Summary: This is the summary of what I did this day

Here I will put all the notes with everything I did that day.

something else

other something else

and in the daily note it will show up like:

# 2023-05-16

---
aliases: [Tue May 16 (2023)]
---

- Project 1: This is the summary of what I did this day

How you write and style custom checklists/tasks like this is up to you, but one way could be to do:

- [a] [[2023-05-15|Mon May 15 (2023)]] The do nothing day

Nothing much done this day, but I made an entry...

$$ 
E = mc^2
$$

- [a] [[2023-05-16|Tue May 16 (2023)]]  This is the summary of what I did this day

Here I will put all the notes with everything I did that day.

something else

other something else

The query to use in a daily note could be something like:

```dataview
TASK
FLATTEN file.link + ": " + regexreplace(text, "^ *\[\[.*?\]\]", "") as visual
WHERE contains(outlinks, [[]])
```

Which using the Minimal theme would display like:
image

Here I’ve removed that link to the daily note, and instead added the “project name” to the start of the line. Either of those is of course optional, and you can change to your preferences.

The extremely nice thing is that you can click on the text of such an entry and get directly to that place within the project note:

image


Similarily you could have another query to summarise your projects like this:

```dataview
TASK
WHERE status = "*"
  AND file.folder = this.file.folder
GROUP BY file.name
```

Displaying as:

image

Still allowing for the backlink on the text of each task. Also note that if you feel like it you can choose to use other status characters, and style them according to wishes. E.g. you could choose to have a given character to indicate that this is a project task summary, or you could designate different characters to different projects, and so on.

1 Like

Hi,

This looks very nice. Does that conflicts somehow with tasks plugin?
I will try that and let you know.

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