Plugin example using sidebar -- with data from current page (like the graph)

Hi there,

The logseq plugin samples page is missing something – how would someone implement a sidebar? In particular, how could you build a component like the graph that uses data about the current page?

I’ve heard of a number of other features requesting sidebar components that refer to the current page, for example requesting a TOC, page specific task list.

The journals calendar sample is closest in overall capability, but it does not render in the sidebar and it does not do anything different depending on the current page context.

An example doing this would enable community contributors to build these kinds of enhancements.

I do see something related in the trello roadmap – but the trello doesn’t say exactly what they’re doing.


Looking through, I believe the best solution would be to tap into the macroRenderer and create it programatically on some random page and then open this block in the sidebar. I think these two TOC plugins are the best option.

hkgnp/logseq-toc-plugin (
This is another option.
sethyuan/logseq-plugin-tocgen: Generate a TOC of any page anywhere to quickly access the page’s content. (

I’d probably follow this general flow.

  1. User calls macro renderer to render sidebar
  2. User clicks a button which opens the block in the sidebar
  3. The renderer shows the graph view, this is the part you need to code
  4. Use the onPageChanged method or something like this, to identify when this happens
  5. Use getCurrentPage to get the page or getCurrentPageBlocksTree to get the blocks in the page
  6. Render this

I hope this is clear. Excited to see what you build!

Looks like the second plugin accomplishes exactly the steps I mentioned!

1 Like

Great example! Thanks!