summaryrefslogtreecommitdiff
path: root/packages/integrations/markdoc/components/Renderer.astro
diff options
context:
space:
mode:
authorGravatar Ben Holmes <hey@bholmes.dev> 2023-03-27 18:04:37 -0400
committerGravatar GitHub <noreply@github.com> 2023-03-27 18:04:37 -0400
commit7c439868a3bc7d466418da9af669966014f3d9fe (patch)
treeaf8a8624a96ed9988f475beaed840df28d864646 /packages/integrations/markdoc/components/Renderer.astro
parentc13d428a7804b5b9809dbea94a1b17c36714a1e1 (diff)
downloadastro-7c439868a3bc7d466418da9af669966014f3d9fe.tar.gz
astro-7c439868a3bc7d466418da9af669966014f3d9fe.tar.zst
astro-7c439868a3bc7d466418da9af669966014f3d9fe.zip
[Markdoc] New config format with runtime variable support! (#6653)
* deps: esbuild * feat: support direct component imports for render! * deps: add devalue back * refactor: remove unused components prop * refactor: load experimental assets config separately * fix: upate Content type def to support props * refactor: replace astro stub with inline data * feat: pass through viteId to getRenderMod * fix: add back $entry var with defaults convention * chore: remove unneeded validateRenderProps * chore: remove uneeded validateComponents * fix: remove userMarkdocConfig prop * chore: add helpful error for legacy config * deps: kleur * fix: add back `isCapitalized` * fix: log instead of throw to avoid scary stacktrace * chore: delete more old logic (nice) * chore: delete MORE unused utils * chore: comment on separate assets config * chore: remove console.log * chore: general code cleanup * test: new render config * docs: new README * fix: add expect-error on astro:assets * feat: add defineMarkdocConfig helper * docs: update example README * test: add runtime variable * chore: lint * chore: changeset * chore: add component import deletion * docs: add notes on Vite fork * fix: astro check * chore: add `.mts` to markdoc config formats
Diffstat (limited to 'packages/integrations/markdoc/components/Renderer.astro')
-rw-r--r--packages/integrations/markdoc/components/Renderer.astro19
1 files changed, 8 insertions, 11 deletions
diff --git a/packages/integrations/markdoc/components/Renderer.astro b/packages/integrations/markdoc/components/Renderer.astro
index 6ae8ee850..5e2b6833a 100644
--- a/packages/integrations/markdoc/components/Renderer.astro
+++ b/packages/integrations/markdoc/components/Renderer.astro
@@ -1,20 +1,17 @@
---
-import type { RenderableTreeNode } from '@markdoc/markdoc';
-import type { AstroInstance } from 'astro';
-import { validateComponentsProp } from '../dist/utils.js';
+import type { Config } from '@markdoc/markdoc';
+import Markdoc from '@markdoc/markdoc';
import { ComponentNode, createTreeNode } from './TreeNode.js';
type Props = {
- content: RenderableTreeNode;
- components?: Record<string, AstroInstance['default']>;
+ config: Config;
+ stringifiedAst: string;
};
-const { content, components } = Astro.props as Props;
+const { stringifiedAst, config } = Astro.props as Props;
-// Will throw if components is invalid
-if (components) {
- validateComponentsProp(components);
-}
+const ast = Markdoc.Ast.fromJSON(stringifiedAst);
+const content = Markdoc.transform(ast, config);
---
-<ComponentNode treeNode={createTreeNode(content, components)} />
+<ComponentNode treeNode={createTreeNode(content)} />