Fetch nested markdown for a journal page?

Hello, I am looking to fetch the markdown of the last 7 days of journal entries. I know I can do something like logseq.DB.q("(between -7d +0d)"), group the blocks by parent, and concatenate together the markdown. But I was wondering if there was an easier way to fetch a page’s entire nested markdown? I didn’t see a way to do this when looking at PageEntity response on PageEntity | @logseq/libs, so posting here for some help. Is there some other way to do this?

You can recursively parse the children of a page entity and use get page blocks tree to only get the top level blocks.

Check out Logseq Schrodinger and Logseq PDF export for examples in action. This basically goes.

query = data script query…

For x in query{
Let tree = getPageBlocksTree(Query[x])
For x in tree {
Recursive loop to look through children.

cool thanks @Aryan, I’ll do something like that. My eventual goal is to create an OPML file, which is also structured like a tree, so I think this should work well.

Welcome. I believe the approach taken in PDF export also passes the depth level on so you get an object from top to bottom with each having an associated depth level as a property. Tats probably the approach that makes the most sense in your case. Excited to see what you build! This is the project with Dave right?

Thanks @Aryan, that’s correct. I just opened a PR to submit the plugin to the plugin store! add logseq-opml-drummer by scottrblock · Pull Request #160 · logseq/marketplace · GitHub