Closed froger closed 2 years ago
Hello @souvikinator ! Thanks for this repo, it's really helpful.
While developing scripts to transform notion pages to Docusaurus markdown (mdx), I've stumbled on a specific need that may help other: I want to change some parsing in a very way, like handling the embed betters.
So here what I've done:
n2m.setCustomTransformer('embed', async (block) => {
const {embed} = block as any;
if (!embed?.url) return '';
return `<figure>
<iframe style={{border: "none"}} width="800" height="450" src="${
embed?.url
}"></iframe>
<figcaption>${await n2m.blockToMarkdown(embed?.caption)}</figcaption>
</figure>`;
});
This way, when the parser have a "embed" type, it executes this function and not the default one. It can fits any other type.
Tradeoffs: The types for ListBlockChildrenResponseResult
have not all the notion types, so it may be needed to do a any
type-casting.
Hello there, Thanks for the contribution. That definitely is an useful feature.
I'll test it locally and create a new release shortly.
Wow that's a pretty awesome feature. Just love it 💯.
It's live in v2.5.0
.