diff options
Diffstat (limited to 'packages/integrations/markdoc/components')
-rw-r--r-- | packages/integrations/markdoc/components/TreeNode.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/packages/integrations/markdoc/components/TreeNode.ts b/packages/integrations/markdoc/components/TreeNode.ts index b9b4c5c4d..f46355d5c 100644 --- a/packages/integrations/markdoc/components/TreeNode.ts +++ b/packages/integrations/markdoc/components/TreeNode.ts @@ -1,6 +1,8 @@ import type { AstroInstance } from 'astro'; import type { RenderableTreeNode } from '@markdoc/markdoc'; import { createComponent, renderComponent, render } from 'astro/runtime/server/index.js'; +// @ts-expect-error Cannot find module 'astro:markdoc-assets' or its corresponding type declarations +import { Image } from 'astro:markdoc-assets'; import Markdoc from '@markdoc/markdoc'; import { MarkdocError, isCapitalized } from '../dist/utils.js'; @@ -45,10 +47,16 @@ export const ComponentNode = createComponent({ propagation: 'none', }); +const builtInComponents: Record<string, AstroInstance['default']> = { + Image, +}; + export function createTreeNode( node: RenderableTreeNode, - components: Record<string, AstroInstance['default']> = {} + userComponents: Record<string, AstroInstance['default']> = {} ): TreeNode { + const components = { ...userComponents, ...builtInComponents }; + if (typeof node === 'string' || typeof node === 'number') { return { type: 'text', content: String(node) }; } else if (node === null || typeof node !== 'object' || !Markdoc.Tag.isTag(node)) { |