souvikinator / notion-to-md

Convert notion pages, block and list of blocks to markdown (supports nesting and custom parsing)
https://www.npmjs.com/package/notion-to-md
MIT License
1.08k stars 89 forks source link

Fix: unable to render synced_block from both ways #89

Closed Doradx closed 1 year ago

Doradx commented 1 year ago

fix the bug when querying children blocks for synced_block.

souvikinator commented 1 year ago

Can you elaborate on the bug you encountered?

Doradx commented 1 year ago

When I use the original code, it can't get the child block of synced_block. Because the child block can't be queried with the ID of the parent block, what I found when I debug with notion API, it should be queried with synced_block.synced_from.block_id.

souvikinator commented 1 year ago

So the content of the synced_block is not getting rendered right? If that is the case then, it works fine on my end:

This is the parent page with a synced block and the child page (Page-1) includes the same synced block. image

output: image

if this is not the issue then please provide steps to reproduce the bug.

Doradx commented 1 year ago

It works fine for the referenced page (page A) but not for the slave page (page B) refers to page A. For example, when you write something on page A, then copy and sync it to page B, the exported markdown files only work fine for page A, not page B. You can find the reason in the response from notion API. Here are the responses from the Notion API for Page A and Page B respectively: Response from Notion, for page A Response from Notion, for page B the UUID of the block is d87824d6-b706-4a1e-b060-878b0c2909b5, and it appeared as the block id for page A, but as synced_block.synced_from.block_id for page B. And the output of sycned_block for page B will be empty if you query its content without using synced_block.synced_from.block_id.

souvikinator commented 1 year ago

Thanks for explaining. That makes it clear. I'll merge it and it should be live in the upcoming update. Thank you for your contribution.