Headers generated with dataviewjs not shown in outline

As of #1581, this is expected behavior.

However, when you use dv.header to compile multiple lists which can grow quite long, the outline would be quite handy to navigate.

My use case:

  • I have a growing list of short notes of a certain type
  • Each note has a field “summary” and a field “keywords”
  • There can be one or more keywords per note
  • I use dataviewjs to compile a list of the corresponding notes for each keyword
  • For each list I put the keyword as heading with dv.header
  • Now, notes and keywords are growing
  • An outline would help to keep the overview on the keywords and to navigate the collection

What would be your approach to solve this?

Remark: I originally asked this question here, but there is hardly any discussion over there :smiley:

I was struggling with this for a while. Then I decided to put them all into nested callouts. With the correct CSS, you can almost make it look like native headers!

Please do present a snippet of how you use callouts from a query to achieve this, @jeetsukumaran

Dataview queries is handled somewhat late in the render process, or slightly different, so that headers and lists don’t behave as if we wrote it directly in markdown. For a pure query I’ve not found a way to get them to be collapsible and included in outline and so on, and I’m not sure what’s required to get it to work “normally”.

One way I’ve used in some occasions is to use Templater to run markdown variants of a query and insert the result into the note. This however removes the dynamic update of the query, and it’s fully static markdown (just generated by a query, and not manually written).

Another way I’ve been playing around with is combining those approaches. That is to have Templater pick up the query from a comment block, and then inserting/replacing the result from the query after that comment block. This is then semiautomatic as it can rerun the query when I trigger the template, and at the same time its result is static and adheres to the normal rules regarding collapsibility, outlines, links, graph view and so on.

Another fancy word for the previous process is to persist the query, which is requested already for dataview, but not implemented. It’s also to be included in datacore, if/when that is released into the public.

Hi @holroy ,

It’s simple once you package the logic away in javascript :wink:

await dv.view(
    "__annex__/resources/obsidian/plugins/dataview/views/productions.dataview",
    {}
)

The rest of it is here due to length. Warning : VERY VERY VERY much a continuously-rolling WIP pre-alpha stage right now.

I am currently rolling my own “CMS” of sorts, to manage output. The three nesting levels are: project area (teaching, research, grants, etc.), => project lane (active, backlog, etc.) => (project). Within each project, there are multiple notes contributing in different ways.

Here are some screenshots of the 'not subtle" design. Apologies for the design – still figuring out the CSS and advanced CSS with selectors etc are really not my strength. I am also working on a rudimental “seamless” design which gives a native appearance but I think that is broken right now due to me renaming some elements.

The nesting can be arbitrarily deep. With default styling it practically becomes unworkable after about 2-3 levels due to the way the backgroud color. And it becomes confusing due to all the callouts having the same color. Custom styling can solve these, at least, to an extent enough for me that I think I could go quite a few levels deeper and not lose orientation.

Templater came to my mind as well. I might give this approach a try this weekend.

Interesting idea! I am just a little concerned that so many collapsible and nested callouts get more confusing than helpful :smile: What about performance on mobile and tablet?

It absolutely can get confusing. When I have time I’ll fuss around with the CSS, but ideally the visual noise would be no more than, for e.g., native headers. The gaudy stuff you see above is just an experiment in the other direction that kinda stuck with me for now. No idea about performance on mobile and tablet – I don’t use those for anything but text messages and wasting time (e.g. Twitter)!

EDIT: found the WIP “seamless” CSS. With this, it is a lot … cleaner :slight_smile:

Can you elaborate a little more on your “combined approach”?

Sorry for the late response, but the gist of the combined approach is this:

  • Mark the query within a comment block (or similar)
  • Make a Templater command which:
    • Reads that query block
    • Executes the query (through Dataview)
    • Replaces, if present, the previous result block

Given that Templater command, you would now be able to re-run the query whenever you feel like it, and it’ll replace the query result with the latest run of the query, and it’ll populate the metadata of links, backlinks, and so on as if it were written statically in the note itself.

The link below discusses this approach in slightly more detail, but it’s still very much a work-in-progess kind of deal.

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