B2B-88: add starter kit structure and elements
This commit is contained in:
30
packages/cms/keystatic/src/markdoc.tsx
Normal file
30
packages/cms/keystatic/src/markdoc.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import React from 'react';
|
||||
|
||||
import { Node } from '@markdoc/markdoc';
|
||||
|
||||
import {
|
||||
CustomMarkdocComponents,
|
||||
CustomMarkdocTags,
|
||||
} from './custom-components';
|
||||
import { MarkdocNodes } from './markdoc-nodes';
|
||||
|
||||
/**
|
||||
* @name renderMarkdoc
|
||||
* @description Renders a Markdoc tree to React
|
||||
*/
|
||||
export async function renderMarkdoc(node: Node) {
|
||||
const { transform, renderers } = await import('@markdoc/markdoc');
|
||||
|
||||
const content = transform(node, {
|
||||
tags: {
|
||||
...CustomMarkdocTags,
|
||||
},
|
||||
nodes: {
|
||||
...MarkdocNodes,
|
||||
},
|
||||
});
|
||||
|
||||
return renderers.react(content, React, {
|
||||
components: CustomMarkdocComponents,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user