I’m trying to replace my dataview scripts with Bases as much as possible.
Now I’m looking for a way to embed a base inside a file that I will embed on multiple locations, trying to keep maintenance on only one place.
What I want:
I have a template/file for people, let’s say writers. In the file of each person-writer, I want a section where I list:
what books he wrote (base-view)
what blog-articles her wrote (base-view)
what podcasts he appeared on (base view)
I want these base views to be separated by headers, so I made a file to create (and edit) that, but I can’t get the bases to refer to the original file.
The current structure would be (for example):
Original file: Cal Newport.md
Embedded file: writer statistics.md with H2-heading “Books”
Embedded base: books.base
How can I filter the Base, based on the original file (Cal Newport.md in this case)?
If you create a base file (as opposed to a base block in an existing file), then you can use the this keyword to refer to the file in which the base is embedded.
For example, I have a “Backlinks.base” file which has the following filter:
The problem is that an embedded file seems to be completely agnostic of the embedding file. Embedding a .base file into your writer/person file works because the writer file parses the base as if it were part of the writer file itself (like using the code block form of bases), not because the base file “knows” anything about the writer file. So the solution by Craig above works for if you filter by writer == this.person_name in my example below, but it won’t work for nested embeds, i.e. a base that is more than one level “below” the writer file.
Cal Newport.md
---
person_name: Cal Newport
---
# Cal Newport
Some text about this writer here ...
![[writer statistics]]
You could have that directly in your writer/person template. Of course it would be convenient to have writer statistics.md as a reusable component that will have any modifications reflected in all writer files, but that doesn’t seem possible for now. I can think of a middle-ground solution where you have it as a “sub-template” that you include in the main writer template via Templater:
The information is available, but it’s a matter of showing it the right way. When I use your setup, I can get this to work (“creator_statistics.md” as an embedded file inside “Cal Newport.md”. A Base called backlinks embedded inside “creator_statistics.md”).
It’s now just a matter of getting file.backlinks as a list in the first column…