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.
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.
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
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.