refactor: optimize rss generation logic

This commit is contained in:
radishzzz 2025-03-17 14:01:51 +00:00
parent f34b0cb46b
commit 0888b59c5f
7 changed files with 128 additions and 155 deletions

View file

@ -5,7 +5,7 @@ import sanitizeHtml from 'sanitize-html'
const parser = new MarkdownIt()
type ExcerptScene = 'list' | 'meta' | 'og'
type ExcerptScene = 'list' | 'meta' | 'og' | 'rss'
// Excerpt length in different scenarios
const EXCERPT_LENGTHS: Record<ExcerptScene, {
@ -24,6 +24,10 @@ const EXCERPT_LENGTHS: Record<ExcerptScene, {
cjk: 75,
other: 150,
},
rss: {
cjk: 120,
other: 240,
},
}
const isCJKLang = (lang: string) => ['zh', 'zh-tw', 'ja'].includes(lang)