fix: add the site path for rss

This commit is contained in:
KazooTTT
2025-02-19 18:22:10 +08:00
parent f5655ef972
commit d3240e607c

View File

@ -25,12 +25,17 @@ export const GET = async () => {
pubDate: post.data.date, pubDate: post.data.date,
link: `posts/${post.id}/`, link: `posts/${post.id}/`,
content: post.body content: post.body
? sanitizeHtml(parser.render(post.body), { ? sanitizeHtml(
allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]), parser
textFilter: function (text: string) { .render(post.body)
return text.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F\uFFF0-\uFFFF]/g, ""); .replace(/<img\s+src="\/images\//g, `<img src="${import.meta.env.SITE}images/`),
{
allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]),
textFilter: function (text: string) {
return text.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F\uFFF0-\uFFFF]/g, "");
},
}, },
}) )
: "", : "",
author: siteConfig.author, author: siteConfig.author,
categories: post.data?.category ? [post.data.category] : [], categories: post.data?.category ? [post.data.category] : [],