diff --git a/src/components/EditorRender.tsx b/src/components/EditorRender.tsx new file mode 100644 index 0000000..f935427 --- /dev/null +++ b/src/components/EditorRender.tsx @@ -0,0 +1,111 @@ +import { PagesRecord } from "@/@types/pocketbase-types"; + +function parseBoldText(text: string) { + const parts = text.split(/(.*?<\/b>)/g); + const result = []; + for (let i = 0; i < parts.length; i++) { + if (parts[i]?.startsWith('')) { + result.push({parts[i]?.slice(3, -4)}) + } else { + result.push(parts[i]) + } + } + return result; +} + +function Paragraph({ text }: { text: string }) { + return
{parseBoldText(text)}
+} + +function Heading({ text, level }: { text: string, level: number }) { + switch (level) { + case 1: + return ( + <> +Unknown block type:
{JSON.stringify(block, null, 2)}
+ }
+ })}
+ {parseBoldText(text)}
-} - -function Heading({ text, level }: { text: string, level: number }) { - switch (level) { - case 1: - return ( - <> -Here is the content rendered:
-Unknown block type:
{JSON.stringify(block, null, 2)}
- }
- })}
- {JSON.stringify(data.content, null, 2)}