11---
2- import { body } from ' ../components/test.mdoc' ;
32import { Markdoc } from ' @astrojs/markdoc' ;
43import RenderMarkdoc from ' ../renderer/RenderMarkdoc.astro' ;
5- import RedP from ' ../components/RedP.astro' ;
6- import { Code } from ' astro/components' ;
7- import { Tag } from ' @markdoc/markdoc' ;
8- import { ComponentRenderer } from ' ../renderer/astroNode' ;
9-
10- const parsed = Markdoc .parse (body );
11- const content = Markdoc .transform (parsed , {
12- variables: {
13- shouldMarquee: true ,
14- href: ' https://astro.build' ,
15- },
16- tags: {
17- mq: {
18- render: ' marquee' ,
19- attributes: {
20- direction: {
21- type: String ,
22- default: ' left' ,
23- matches: [' left' , ' right' , ' up' , ' down' ],
24- errorLevel: ' critical' ,
25- },
26- },
27- },
28- link: {
29- render: ' a' ,
30- attributes: {
31- href: {
32- type: String ,
33- required: true ,
34- },
35- },
36- },
37- },
38- });
394
40- const code: ComponentRenderer = {
41- component: Code ,
42- props({ attributes , getTreeNode }) {
43- return {
44- ... attributes ,
45- lang: attributes .lang ?? attributes [' data-language' ],
46- code: attributes .code ?? Markdoc .renderers .html (getTreeNode ().children ),
47- };
48- },
49- };
5+ import { getTransformed } from ' ../components/test.mdoc' ;
6+ import { Code } from ' astro/components' ;
7+ import Marquee from ' ../components/Marquee.astro' ;
508---
519
5210<html lang =" en" >
@@ -61,11 +19,19 @@ const code: ComponentRenderer = {
6119 <h1 >Astro</h1 >
6220 <article >
6321 <RenderMarkdoc
64- content ={ content }
22+ content ={ await getTransformed () }
6523 components ={ {
66- p: RedP ,
67- code ,
68- pre: code ,
24+ marquee: Marquee ,
25+ pre: {
26+ component: Code ,
27+ props({ attributes , getTreeNode }) {
28+ return {
29+ ... attributes ,
30+ lang: attributes .lang ?? attributes [' data-language' ],
31+ code: attributes .code ?? Markdoc .renderers .html (getTreeNode ().children ),
32+ };
33+ },
34+ },
6935 }}
7036 />
7137 </article >
0 commit comments