Pre Parser
Pre Parser as the name suggests is a step we take before passing data to the <Parser />
itself.
Main objective here is to collect children of blocks like table
or nested lists
, because the <Parser />
Component renders the passed data only and if any complex blocks are found they are silently overlooked.
ℹ️
If want to render table
or nested lists
, this step is mandatory.
Implementation
- It takes two parameters, that are
blocks
the original blocks fetched andgetBlocks
function itself. usePreParser
is a async function and should be handled carefully to avoid unnecessary errors.
import { Parser, usePreParser } from "tetrapack";
export default async function Home() {
let blocks = await getBlocks(process.env.NOTION_PAGE_ID);
blocks = await usePreParser(blocks, getBlocks);
return (
<Parser blocks={blocks} />
);
}