fix: fix RSS build error
This commit is contained in:
parent
4518dbf0f8
commit
1af707ee6a
|
@ -15,13 +15,12 @@ export async function GET(context: APIContext) {
|
|||
description: siteConfig.subtitle || 'No description',
|
||||
site: context.site ?? 'https://fuwari.vercel.app',
|
||||
items: blog.map(post => {
|
||||
const body = typeof post.data.body === 'string' ? post.data.body : ''
|
||||
return {
|
||||
title: post.data.title,
|
||||
pubDate: post.data.published,
|
||||
description: post.data.description || '',
|
||||
link: `/posts/${post.slug}/`,
|
||||
content: sanitizeHtml(parser.render(body), {
|
||||
content: sanitizeHtml(parser.render(post.body), {
|
||||
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img']),
|
||||
}),
|
||||
}
|
||||
|
|
|
@ -4,14 +4,14 @@ import I18nKey from '@i18n/i18nKey'
|
|||
import { i18n } from '@i18n/translation'
|
||||
|
||||
export async function getSortedPosts(): Promise<
|
||||
{ data: BlogPostData; slug: string }[]
|
||||
{ body: string, data: BlogPostData; slug: string }[]
|
||||
> {
|
||||
const allBlogPosts = (await getCollection('posts', ({ data }) => {
|
||||
return import.meta.env.PROD ? data.draft !== true : true
|
||||
})) as unknown as { data: BlogPostData; slug: string }[]
|
||||
})) as unknown as { body: string, data: BlogPostData; slug: string }[]
|
||||
|
||||
const sorted = allBlogPosts.sort(
|
||||
(a: { data: { published: Date } }, b: { data: { published: Date } }) => {
|
||||
(a: { data: BlogPostData }, b: { data: BlogPostData }) => {
|
||||
const dateA = new Date(a.data.published)
|
||||
const dateB = new Date(b.data.published)
|
||||
return dateA > dateB ? -1 : 1
|
||||
|
|
Loading…
Reference in New Issue