It would be neat to automatically assign tags (= page references) to blocks based on the results of a simple or advanced query. This is useful in situations, where the tag can be derived by looking at the block’s content, so the block does not need to be tagged manually.
The name can be a link to an existing page OR a new “dynamic” page (there might be a better term).
Dynamic page = create a name for query results and refer to them by using this name in the same way as normal page links.
Example 1: Assign page name Logseq Discourse
to all blocks with content https://discuss.logseq.com
. That should give us all blocks with a forum URL, like
- Link to the forum: https://discuss.logseq.com/
- [My feature request](https://discuss.logseq.com/t/allow-to-use-more-clojure-functions-in-advanced-queries-akin-to-datomic-graph-traversal/16275)
Now it’s like all forum URLs have a page link [[Logseq Discourse]]
, but done done automatically! We are able refer to this set of queried blocks in other places:
- Find all forum discussions [here]([[Logseq Discourse]])
Where to actually declare this name "Logseq Discourse"
and connect it to a query?
I am not sure, it can be a dummy page with a query as content. But it would be wasteful to create dummy pages and markdown files only to get a name, so might define these on a block level:
- dynamic-page:: Logseq Discourse
{{query "https://discuss.logseq.com"}}
Example 2: Find all Markdown codeblocks and give them a name [[My code blocks]]
.
- dynamic-page:: My code blocks
{{query "```"}}
- dynamic-page:: My Python code blocks
{{query "```python"}}
Example 3: Compose dynamic pages from smaller components
Think LEGO . Build up more complex things from smaller bricks. First, have everything related to Clojure docs under name
[[Clojure documentation]]
:
- dynamic-page:: Clojure documentation
{{query (or "https://clojure.org" "https://clojuredocs.org")}}
Then collect everything Clojure-related under [[All about Clojure]]
, reusing above name:
- dynamic-page:: All about Clojure
{{query (or [[Clojure]] [[Clojure documentation]])}}
[[Clojure]]
is a normal page here. Now link to [[All about Clojure]]
.
Advantages
- Incoorporate queries naturally into Logseq via page links we all know.
- Craft once, reuse everywhere
- Might be useful for newcomers, that don’t know how to write more complex queries. Get help, copy paste it and don’t care about implementation.
- No manual tagging of blocks in those cases, where page link can be derived by looking at block content or context (via queries). Examples: URLs, Markdown codeblocks, quotes, Regex.