用 Markdoc 而非 Markdown 渲染博客,以在未来支持自定义元素
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -1,11 +1,12 @@
|
||||
---
|
||||
import { getBlog } from '../../lib/apis/legacy/blog'
|
||||
import BaseLayout from '../../layout/BaseLayout.astro'
|
||||
import { renderMarkdown } from '../../lib/markdown'
|
||||
import { MarkdocTreeRender } from '../../components/MarkdocRenderer.tsx'
|
||||
import { toMarkdocTree } from '../../lib/markdoc'
|
||||
|
||||
export const prerender = false
|
||||
|
||||
const { blog_id } = Astro.params
|
||||
const { blog_id = '' } = Astro.params
|
||||
const blog_id_num = parseInt(blog_id)
|
||||
|
||||
if (isNaN(blog_id_num) || blog_id_num < 0) {
|
||||
@ -17,7 +18,10 @@ if (blogData === null) {
|
||||
return Astro.redirect('/404')
|
||||
}
|
||||
|
||||
const blogRendered = await renderMarkdown(blogData.content)
|
||||
const tree = await toMarkdocTree(blogData.content)
|
||||
---
|
||||
|
||||
<BaseLayout set:html={blogRendered} />
|
||||
<!-- <BaseLayout set:html={blogRendered} /> -->
|
||||
<BaseLayout>
|
||||
<MarkdocTreeRender tree={tree} client:load />
|
||||
</BaseLayout>
|
||||
|
||||
Reference in New Issue
Block a user