fix: fixed the problem of not rendering mdx article content properly

This commit is contained in:
Guoqi Sun 2024-12-22 16:24:52 +08:00
parent f708712a3b
commit 0cca11aec6
3 changed files with 10 additions and 5 deletions

View file

@ -10,10 +10,6 @@ image:
tags: ["astro", "blogging", "learning-in-public"]
---
# My First Blog Post
Published on: 2020-07-01
Welcome to my _new blog_ about learning Astro! Here, I will share my learning journey as I build a new website.
## What I've accomplished

View file

@ -10,6 +10,10 @@ image:
tags: ["astro", "博客", "公开学习"]
---
export const title = "mdx"
## {title}
欢迎来到我学习关于 Astro 的新博客!在这里,我将分享我建立新网站的学习历程。
## 我做了什么

View file

@ -1,4 +1,5 @@
---
import { render } from "astro:content"
import { langs } from "~/i18n/ui"
import { getLangFromUrl } from "~/i18n/utils"
import MainLayout from "~/layouts/main.astro"
@ -24,6 +25,8 @@ export async function getStaticPaths() {
const lang = getLangFromUrl(Astro.url)
const { post } = Astro.props
const { Content } = await render(post)
---
<MainLayout {...post.data}>
@ -35,7 +38,9 @@ const { post } = Astro.props
</div>
</div>
<div class="my-6" set:html={post.rendered.html} />
<div class="my-6">
<Content />
</div>
<div class="space-x-3 pb-10 text-sm text-gray-500">
{