优化 RSS
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-04-01 02:48:35 +08:00
parent c6bc10d6cd
commit b32c5bc6e9

View File

@ -6,7 +6,7 @@ import {
type ListBlogItemType,
} from '../lib/apis/legacy/blog'
import { ensureShikiEngine } from '../lib/markdown'
import { toMarkdocTree } from '../lib/markdoc'
// import { toMarkdocTree } from '../lib/markdoc'
import Markdoc from '@markdoc/markdoc'
export const prerender = false
@ -36,7 +36,8 @@ export const GET = (async (context) => {
blogs.map(async (blog) => {
const blogContent =
(await getBlog(blog.id))?.content || '博客内容暂不可用'
const blogTree = await toMarkdocTree(blogContent)
// const blogTree = await toMarkdocTree(blogContent)
const blogTree = Markdoc.transform(Markdoc.parse(blogContent))
const html = Markdoc.renderers.html(blogTree)
const rssItem: RSSFeedItem = {
@ -45,6 +46,14 @@ export const GET = (async (context) => {
link: `${site}/blogs/${blog.id}`,
pubDate: new Date(blog.created_at),
content: html,
author: blog.author.nickname,
enclosure: blog.featured_image
? {
url: blog.featured_image.image_url,
length: 0,
type: 'image/jpeg',
}
: undefined,
}
return rssItem