Querying latest three text blocks with a tag

Things I have tried

Since I don’t know how to target individual blocks, not pages - and the wiki says blocks are not dataview sources, I was thinking of targeting tasks as a workaround. Which means that three of the latest tasks with a certain tag could show up.

What I’m trying to do

This would allow me to build something like this in dataview:

Anytime I have an update on the matter, I would just leave a simple text block with an appropriate tag in any of the “daylies” and it would get picked up.

Here’s a similar thread: List all code blocks using dataview - #2 by gcervera

@mnvwvnm said there:

Currently that’s not possible.
You can pull a request in the plugin page. The developer is very helpful.

Hi. I don’t understand well the intended. Do you want the content of some blocks in your dataview query?
Blocks, not codeblocks…

Well, it is kind of related. Codeblocks are blocks, but consisting of code. And since you can’t query codeblocks (i.e. TABLE dv.block WHERE contains(''') or something like that) then any other block is also not possible, i assume.

1 Like

Not so true…
Let’s say you consider your text blocks as a value in a field, using the syntax of full inline-field: key:: value
Something like this:

mykey:: Nam sollicitudin, diam ut vulputate dictum, ipsum lectus tristique arcu, gravida luctus nisl neque at nisl. Nunc maximus nibh eget justo consectetur, ac euismod augue congue. Nam ac dignissim libero, sit amet gravida nunc. Phasellus eget eros non nulla tempus rhoncus quis eu justo. Nulla et ultrices erat. Suspendisse lacinia placerat ultricies.

All the text in the same line (without paragraph) works like a value in the field “mykey”. You can use multiples…

## my file

mykey:: Lorem ipsum dolor sit amet, consectetur adipiscing elit.

other text blocks

mykey:: Cras volutpat convallis orci nec tristique. Morbi finibus faucibus augue, at suscipit dui dapibus vitae. Maecenas bibendum tortor ut egestas maximus.

something else

mykey:: Nam sollicitudin, diam ut vulputate dictum, ipsum lectus tristique arcu, gravida luctus nisl neque at nisl.

dataview

3 Likes

Interesting. If I were to annotate my “project updates” with something like project::sample and queried for this string, it would be doable.

Now the problem would be… how to leave only three most recent updates and discard the rest from this dv.array (or whathever this object is called)?

Well, that’s a task for js experts (I’m a ‘zero’ in js). :slight_smile:
Here you can find limit and slice functions…
https://blacksmithgu.github.io/obsidian-dataview/api/data-array/

1 Like

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