Skip to content

Commit 1c50168

Browse files
committed
fix: build errors and enhance xml
1 parent 550c75e commit 1c50168

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

astro.config.mjs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,20 @@ export default defineConfig({
6262
svelte(),
6363
sitemap(),
6464
Compress({
65-
CSS: true,
65+
CSS: {
66+
lightningcss: {
67+
minify: true,
68+
sourceMap: false,
69+
drafts: {
70+
nesting: true,
71+
},
72+
errorRecovery: true, // 添加错误恢复选项
73+
},
74+
},
6675
HTML: {
6776
'html-minifier-terser': {
6877
removeAttributeQuotes: false,
78+
decodeEntities: true, // 解码 HTML 实体
6979
},
7080
},
7181
Image: false,

src/pages/rss.xml.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import rss from '@astrojs/rss';
22
import type { APIContext } from 'astro';
3-
import MarkdownIt from 'markdown-it';
4-
import sanitizeHtml from 'sanitize-html';
53

64
import { siteConfig } from '@/config';
75
import { getSortedPosts } from '@utils/content-utils';
86

9-
const parser = new MarkdownIt();
10-
117
export async function GET(context: APIContext) {
128
const blog = await getSortedPosts();
139

@@ -20,12 +16,15 @@ export async function GET(context: APIContext) {
2016
title: post.data.title,
2117
pubDate: post.data.published,
2218
description: post.data.description || '',
23-
link: `/posts/${post.slug}/`,
24-
content: sanitizeHtml(parser.render(post.body), {
25-
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img']),
26-
}),
19+
link: `${context.site}/posts/${post.slug}/`,
2720
};
2821
}),
29-
// customData: `<language>${siteConfig.lang}</language>`,
22+
customData: `
23+
<language>${siteConfig.lang.replace('_', '-')}</language>
24+
<follow_challenge>
25+
<feedId>${import.meta.env.FOLLOW_FEEDID}</feedId>
26+
<userId>${import.meta.env.FOLLOW_USERID}</userId>
27+
</follow_challenge>
28+
`,
3029
});
3130
}

0 commit comments

Comments
 (0)