From 92c659a7b800da0fe4ad5d6fbd2b145281894fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A2=E3=83=94=E3=83=8C?= Date: Sun, 30 Mar 2025 18:32:05 +0200 Subject: [PATCH] fix: MarkdownIt String error when md file body is empty (#303) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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: アピヌ Co-authored-by: L4Ph <4ranci0ne@gmail.com> Co-authored-by: Katsuyuki Karasawa --- src/pages/rss.xml.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/rss.xml.ts b/src/pages/rss.xml.ts index 2b733f4b..6afa5cde 100644 --- a/src/pages/rss.xml.ts +++ b/src/pages/rss.xml.ts @@ -15,12 +15,15 @@ export async function GET(context: APIContext) { description: siteConfig.subtitle || 'No description', site: context.site ?? 'https://fuwari.vercel.app', items: blog.map(post => { + const content = + typeof post.body === 'string' ? post.body : String(post.body || '') + return { title: post.data.title, pubDate: post.data.published, description: post.data.description || '', link: `/posts/${post.slug}/`, - content: sanitizeHtml(parser.render(post.body), { + content: sanitizeHtml(parser.render(content), { allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img']), }), }