-
-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a custom transformer for synced blocks produces double output #62
Comments
So I tried it out and the synced block is not getting ignored when not using Now custom transformer does produce duplicate output but only for |
Sorry, you're right, the content wasn't ignored per se. Here is my function for getting the content of the synced blocks. I am only getting the first child each time, I only have a single block in the synced blocks, maybe that's an edge case, not sure: /**
* Replacing synced blocks is returning either the synced block, or
* the first child of the synced block, and keep going until you reach
* a non-synced block.
*/
const replaceSyncedBlockWithTarget = async (
block: NotionBlock,
client: Client
): Promise<NotionBlock> => {
if (block.type !== "synced_block") {
return block;
}
const synced_from = block?.synced_block?.synced_from?.block_id;
if (synced_from) {
const syncedBlock = await client.blocks.retrieve({ block_id: synced_from });
return await replaceSyncedBlockWithTarget(
syncedBlock as NotionBlock,
client
);
}
const children = await client.blocks.children.list({ block_id: block.id });
if (children.results.length === 0) {
return block;
}
return await replaceSyncedBlockWithTarget(
children.results[0] as NotionBlock,
client
);
}; |
This issue is fixed and is live in v3.0.0 |
I'm using docu-notion which consumes this module.
I created a custom transformer for synced blocks since they were getting ignored.
However, the markdown output is doubled. Somehow the transform function is getting called twice.
The code for handling synced blocks is a bit unclear.
I suspect it's complicated by that for synced blocks, you need to dig into the children and then follow the synced blocks there. But even if my custom transformer just returns some hard-coded text string, that output is also doubled, so the doubling is not due to the custom transformer, it's seems the problem is upstream.
Relevant notion doc:
Then the relevant output is:
The transformer to test is:
The text was updated successfully, but these errors were encountered: