@@ -25,26 +25,31 @@ export default (): LoaderPlugin => {
25
25
transform : ( { content } ) => {
26
26
const { __content, ...meta } = safeLoadFront ( decoder . decode ( content ) )
27
27
const html = marked . parse ( __content )
28
+ const framework = Deno . env . get ( 'ALEPH_FRAMEWORK' )
28
29
const props = {
29
30
id : util . isString ( meta . id ) ? meta . id : undefined ,
30
31
className : util . isString ( meta . id ) ? meta . className : undefined ,
31
32
style : util . isPlainObject ( meta . style ) ? meta . style : undefined ,
32
33
}
33
34
34
- return {
35
- code : [
36
- `import { createElement } from 'https://esm.sh/react'` ,
37
- `import HTMLPage from 'https://deno.land/x/aleph/framework/react/htmlpage.ts'` ,
38
- `export default function MarkdownPage(props) {` ,
39
- ` return createElement(HTMLPage, {` ,
40
- ` ...${ JSON . stringify ( props ) } ,` ,
41
- ` ...props,` ,
42
- ` html: ${ JSON . stringify ( html ) } ` ,
43
- ` })` ,
44
- `}` ,
45
- `MarkdownPage.meta = ${ JSON . stringify ( meta ) } ` ,
46
- ] . join ( '\n' )
35
+ if ( framework === 'react' ) {
36
+ return {
37
+ code : [
38
+ `import { createElement } from 'https://esm.sh/react'` ,
39
+ `import HTMLPage from 'https://deno.land/x/aleph/framework/react/components/HTMLPage.ts'` ,
40
+ `export default function MarkdownPage(props) {` ,
41
+ ` return createElement(HTMLPage, {` ,
42
+ ` ...${ JSON . stringify ( props ) } ,` ,
43
+ ` ...props,` ,
44
+ ` html: ${ JSON . stringify ( html ) } ` ,
45
+ ` })` ,
46
+ `}` ,
47
+ `MarkdownPage.meta = ${ JSON . stringify ( meta ) } ` ,
48
+ ] . join ( '\n' )
49
+ }
47
50
}
51
+
52
+ throw new Error ( `markdown-loader: don't support framework '${ framework } '` )
48
53
}
49
54
}
50
55
}
0 commit comments