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

Commit cfc18a0

Browse files
committed
refactor: improve markdown loader
1 parent 093d77c commit cfc18a0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

plugins/markdown.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,23 @@ export default (): LoaderPlugin => {
2424
},
2525
transform: ({ content }) => {
2626
const { __content, ...meta } = safeLoadFront(decoder.decode(content))
27+
const html = marked.parse(__content)
2728
const props = {
2829
id: util.isString(meta.id) ? meta.id : undefined,
2930
className: util.isString(meta.id) ? meta.className : undefined,
3031
style: util.isPlainObject(meta.style) ? meta.style : undefined,
31-
html: marked.parse(__content)
3232
}
3333

3434
return {
3535
code: [
3636
`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() {`,
39-
` return createElement(HTMLPage, ${JSON.stringify(props)})`,
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+
` })`,
4044
`}`,
4145
`MarkdownPage.meta = ${JSON.stringify(meta)}`,
4246
].join('\n')

0 commit comments

Comments
 (0)