Can dataview display context information like query?

Hi, I am a beginner for obsidian and dataview.

The following is my use case:

I have a lot of notes that tagged with #todo.

Now I’d like to filter all #todo in the vault and show them in the index.md.

For example,

index.md

```query
#todo
```

The query will filter all the #todo occurrences which include context preview that embedded in my note.

However, this method doesn’t seem to recognize YAML metadata, like:

---
created: "2022-09-30 03:20"
title: todo
tags: [todo]
---

So I want to use dataview instead, e.g.

```dataview
table
from #todo
```

However, dataview cannot display context preview.

My question is that

  1. Can the query language recognize files that just contains tags in metadata?

  2. Can dataview display context information like query language?

Very thanks!

Dataview works with metadata, not the full content. You can use inline fields, tasks or bullet lists to play with some specific “content”. For example:

## inline fields

summary:: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu magna id est interdum euismod id at lectus. Aliquam aliquam, lectus at cursus volutpat, mi libero malesuada enim, in iaculis augue elit ut tellus. Aenean dignissim lorem non urna tempus sollicitudin.

## bullet list
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur eu magna id est interdum euismod id at lectus. [field:: todo]
- Aliquam aliquam, lectus at cursus volutpat, mi libero malesuada enim, in iaculis augue elit ut tellus. Aenean dignissim lorem non urna tempus sollicitudin.

## tasks
- [ ] this is a task with a #todo

About the query way, I think that’s no possible. But also, what kind of context you image to see if the wanted tag is placed in frontmatter and no in the content? Preview what? Some lines before and after?

I have not tried inline fields, tasks or bullet lists. Thank you for telling me this information. I will look into it.

For query way, it is not a “Preview Problem”, it can’t search those files at all!

See Obsidian help site:

As of 0.12.12, there are four keys natively supported:

which means that these metadata in the YAML front matter are not dataview’s feature, they are Obsidian’s feature. I think Obsidian ought to be able to organize for these tags.

Do you think it is a bug? If you think so too, I could report a bug.

P.s. Of course, it can be workaround by add a normal tag (e.g. #todo) in the head of my markdown file. (But that means there are duplicate tags.)

Sorry but I still don’t understand the point:

  1. If you want to see some context, you can use the query way (tag + context).
  2. If you’re interested in tags placed in yaml frontmatter, then you’re not interested in the context, only the pages where you’ve that tag.
  3. For last cases you can use dataview. You can use dataview to list pages where you have the wanted tag, placed in frontmatter or in the main content.

An extra point. Instead of

```query
#todo
```

you can use

```query
tag: todo
```

You will see the cases with tag in yaml, but, obviously, without context.

1 Like

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