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.
This is another option.
sethyuan/logseq-plugin-tocgen: Generate a TOC of any page anywhere to quickly access the page’s content. (github.com)
I’d probably follow this general flow.
- User calls macro renderer to render sidebar
- User clicks a button which opens the block in the sidebar
- The renderer shows the graph view, this is the part you need to code
- Use the onPageChanged method or something like this, to identify when this happens
- Use getCurrentPage to get the page or getCurrentPageBlocksTree to get the blocks in the page
- Render this
I hope this is clear. Excited to see what you build!
Looks like the second plugin accomplishes exactly the steps I mentioned!