Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 171ede1

Browse files
committed
Fix markdown loader plugin
1 parent a6b3eca commit 171ede1

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

plugins/markdown.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,31 @@ export default (): LoaderPlugin => {
2525
transform: ({ content }) => {
2626
const { __content, ...meta } = safeLoadFront(decoder.decode(content))
2727
const html = marked.parse(__content)
28+
const framework = Deno.env.get('ALEPH_FRAMEWORK')
2829
const props = {
2930
id: util.isString(meta.id) ? meta.id : undefined,
3031
className: util.isString(meta.id) ? meta.className : undefined,
3132
style: util.isPlainObject(meta.style) ? meta.style : undefined,
3233
}
3334

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+
}
4750
}
51+
52+
throw new Error(`markdown-loader: don't support framework '${framework}'`)
4853
}
4954
}
5055
}

0 commit comments

Comments
 (0)