Add :pages to :default-queries in config

Currently in the config file it’s possible to have queries that run on the journal page by adding queries to :default-queries { :journals [] }.

I’d like if I was able to add a custom query that ran on any page I’m viewing. Basically a way for me to bubble up or collect things on that page. “Show me all todo items in this page that have the tag ‘Important’”, for example.

Maybe add another option to :default-queries called :pages? And any advanced queries that are added to it would be run on any currently open page.

I know you can add queries to a page with /Query. I’m wanting something that is automatically run on any page I am viewing.

I’d use this also. I create a lot of TODOs tagged with people or meetings where i need to discuss the topic. It’s nice for organically developing meeting agendas. The “Linked References” section can get pretty cluttered over time so having the ability to include a custom query would allow me to easily see all unaddressed agenda items for a given person/meeting without having to manually add the query to every page i create.

Edit: I did just discover that you can apply a filter to the linked references to only list TODO items. That’s really nice. I’d still prefer a custom query though so i dont have to modify the filter back and forth all the time. Also, if i wanted to do anything more complex like a date filter i’d be stuck.

2 Likes

I would use this for showing my query “What happened on this day?” for every journal day and not only on the current day. Since today (version 0.8.16) the :current-page input is available, this would be possible, I guess.

I was actually thinking about this and I think this feature would have a ton of potential for great uses.

For example, imagine I want to add a button to all my pages that says “Open in VS Code” and when pressing the button, it opens the Logseq page in VS Code. I could simply have the following query appear on all pages:

#+BEGIN_QUERY
 {
:query [:find (pull ?f [:file/path])
      :in $ ?current-page
      :where
      [?p :block/name ?current-page]
      [?p :block/file ?f]
]
:inputs [:current-page]
:result-transform (fn [results] (map :file/path results))
:view (fn [result]
       [:div.flex.flex-col
        (for [file result]
          [:a {:href (str "vscode://file" file)} "Open in vs code"])])
}
#+END_QUERY

I can easily see how this idea could be expanded to have custom UI elements added to pages and a lot of interesting pieces of functionality.

It’s probably not exactly the same for your future needs, but if you just want to open the file in your default editor, you can use the menu point for each page (the three dots).

1 Like

What if, to better handle all use cases at once, we were able to define in config.edn default content that appears on top and at the bottom of a page?

I mean not only queries. Put whatever you want in the “top section” or in the “botton section”, including but not limited to queries.

2 Likes

This is absolutely necessary, is there maybe a plugin that can improve the page layout like this?

A workaround are contextual queries in the sidebar:

Just in case a plugin moved these queries from the sidebar to top/bottom of the page, would it be enough for you?

Personally I prefer the sidebar because I don’t need to scroll long pages.

1 Like

thank you very much, this is sufficient for me at the moment,
it would be nice to have it automatically on each page like within the diary pages, but it works :slight_smile:

how did you hide the query/live query menu?

1 Like

With the custom CSS I published here:

Copy-paste it in /your-graph/logseq/custom.css and then tag with #mininal-query the blocks containing the queries that you want to style.

1 Like

thank you very much!

1 Like

I would like to know if we still cannot change default queries within all pages and if it’s not planned for the future?

Found this post and it seems like it’s not a feature:

And I blindly tried out on my config.edn and obviously doesn’t work when putting default-queries under :pages, only :journals…

The mentioned “contextual sidebar” is a kind of alternative?, but not a solution: it does not only not update automatically, but it doesn’t look/exist in the same way as a default query in the page structure/html + it also opens in any page including journals which has its own default-queries.

Adding a custom query for each page, specially when you also cannot have an built-in dynamic query, makes it difficult to manage and it’s inefficient.

I think this thread is still relevant.