mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-17 12:01:33 +02:00
feat: enhance internationalization support with dynamic routing
This commit is contained in:
parent
d6c98880d3
commit
8c19d26cfd
12 changed files with 199 additions and 87 deletions
|
@ -24,11 +24,13 @@ function getExcerpt(content: string): string {
|
|||
return `${plainText.slice(0, 100).trim()}...`
|
||||
}
|
||||
|
||||
// Generate RSS feed
|
||||
export async function GET(_context: APIContext) {
|
||||
// Generate RSS feed for default language
|
||||
export async function GET() {
|
||||
// Only handle posts for default language
|
||||
const posts = await getCollection(
|
||||
'posts',
|
||||
({ data }: { data: CollectionEntry<'posts'>['data'] }) => !data.draft,
|
||||
({ data }: { data: CollectionEntry<'posts'>['data'] }) =>
|
||||
(!data.draft && (data.lang === locale || data.lang === '')),
|
||||
)
|
||||
|
||||
return rss({
|
||||
|
@ -36,6 +38,7 @@ export async function GET(_context: APIContext) {
|
|||
description,
|
||||
site: url,
|
||||
stylesheet: '/rss/styles.xsl',
|
||||
// Map posts to RSS items
|
||||
items: posts.map((post: CollectionEntry<'posts'>) => ({
|
||||
title: post.data.title,
|
||||
pubDate: post.data.published,
|
||||
|
@ -48,13 +51,14 @@ export async function GET(_context: APIContext) {
|
|||
},
|
||||
),
|
||||
})),
|
||||
// Add language and follow challenge info
|
||||
customData: `
|
||||
<language>${locale}</language>
|
||||
${followConfig?.feedID && followConfig?.userID
|
||||
? `<follow_challenge>
|
||||
<feedId>${followConfig.feedID}</feedId>
|
||||
<userId>${followConfig.userID}</userId>
|
||||
</follow_challenge>`
|
||||
<feedId>${followConfig.feedID}</feedId>
|
||||
<userId>${followConfig.userID}</userId>
|
||||
</follow_challenge>`
|
||||
: ''
|
||||
}
|
||||
`.trim(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue