diff --git a/.changeset/nasty-pandas-unite.md b/.changeset/nasty-pandas-unite.md new file mode 100644 index 0000000000..d8d73fa349 --- /dev/null +++ b/.changeset/nasty-pandas-unite.md @@ -0,0 +1,5 @@ +--- +'@astrojs/markdoc': patch +--- + +Fixes rendering components when the `nodes.document.render` Markdoc config is set to `null` diff --git a/packages/integrations/markdoc/components/TreeNode.ts b/packages/integrations/markdoc/components/TreeNode.ts index d63ca8c1c3..4c1174c3c5 100644 --- a/packages/integrations/markdoc/components/TreeNode.ts +++ b/packages/integrations/markdoc/components/TreeNode.ts @@ -40,7 +40,11 @@ export type TreeNode = function renderTreeNodeToFactoryResult(result: SSRResult, treeNode: TreeNode) { if (Array.isArray(treeNode)) { - return Promise.all(treeNode.map((node) => renderTreeNodeToFactoryResult(result, node))); + return Promise.all( + treeNode.map((node) => + renderComponent(result, 'ComponentNode', ComponentNode, { treeNode: node }), + ), + ); } if (treeNode.type === 'text') return render`${treeNode.content}`; diff --git a/packages/integrations/markdoc/test/fixtures/render-null/markdoc.config.mjs b/packages/integrations/markdoc/test/fixtures/render-null/markdoc.config.mjs index 01082bfacd..5db65fddd5 100644 --- a/packages/integrations/markdoc/test/fixtures/render-null/markdoc.config.mjs +++ b/packages/integrations/markdoc/test/fixtures/render-null/markdoc.config.mjs @@ -1,10 +1,15 @@ -import { defineMarkdocConfig, nodes } from '@astrojs/markdoc/config'; +import { defineMarkdocConfig, nodes, component } from '@astrojs/markdoc/config'; export default defineMarkdocConfig({ nodes: { document: { ...nodes.document, render: null, - } - } -}) + }, + }, + tags: { + 'div-wrapper': { + render: component('./src/components/DivWrapper.astro'), + }, + }, +}); diff --git a/packages/integrations/markdoc/test/fixtures/render-null/src/components/DivWrapper.astro b/packages/integrations/markdoc/test/fixtures/render-null/src/components/DivWrapper.astro new file mode 100644 index 0000000000..942a11945f --- /dev/null +++ b/packages/integrations/markdoc/test/fixtures/render-null/src/components/DivWrapper.astro @@ -0,0 +1 @@ +