1
1
---
2
- import { body } from ' ../components/test.mdoc' ;
3
2
import { Markdoc } from ' @astrojs/markdoc' ;
4
3
import 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
- });
39
4
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' ;
50
8
---
51
9
52
10
<html lang =" en" >
@@ -61,11 +19,19 @@ const code: ComponentRenderer = {
61
19
<h1 >Astro</h1 >
62
20
<article >
63
21
<RenderMarkdoc
64
- content ={ content }
22
+ content ={ await getTransformed () }
65
23
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
+ },
69
35
}}
70
36
/>
71
37
</article >
0 commit comments