mirror of
https://github.com/saicaca/fuwari.git
synced 2026-01-11 14:52:52 +01:00
fix: MarkdownIt String error when md file body is empty (#303)
* Fix: MarkdownIt String error Fixed MardownIt String error that occurs when a md file body is empty * fix dependabot.yml * fix parsing error * refactor: simplify content handling in RSS feed generation --------- Co-authored-by: アピヌ <apynu@users.noreply.github.com> Co-authored-by: L4Ph <4ranci0ne@gmail.com> Co-authored-by: Katsuyuki Karasawa <me@l4ph.moe>
This commit is contained in:
@@ -15,12 +15,15 @@ export async function GET(context: APIContext) {
|
|||||||
description: siteConfig.subtitle || 'No description',
|
description: siteConfig.subtitle || 'No description',
|
||||||
site: context.site ?? 'https://fuwari.vercel.app',
|
site: context.site ?? 'https://fuwari.vercel.app',
|
||||||
items: blog.map(post => {
|
items: blog.map(post => {
|
||||||
|
const content =
|
||||||
|
typeof post.body === 'string' ? post.body : String(post.body || '')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: post.data.title,
|
title: post.data.title,
|
||||||
pubDate: post.data.published,
|
pubDate: post.data.published,
|
||||||
description: post.data.description || '',
|
description: post.data.description || '',
|
||||||
link: `/posts/${post.slug}/`,
|
link: `/posts/${post.slug}/`,
|
||||||
content: sanitizeHtml(parser.render(post.body), {
|
content: sanitizeHtml(parser.render(content), {
|
||||||
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img']),
|
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img']),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user