mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 19:51:07 +02:00
refactor: theme config
This commit is contained in:
parent
8f8cda2717
commit
696fcfac07
15 changed files with 224 additions and 293 deletions
27
src/pages/[lang]/atom.xml.ts
Normal file
27
src/pages/[lang]/atom.xml.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import type { APIContext } from 'astro'
|
||||
import themeConfig from '@/config'
|
||||
import { generateRSS } from '@/utils/rss'
|
||||
|
||||
const { moreLocale } = themeConfig.global
|
||||
|
||||
// Type for supported non-default languages
|
||||
type SupportedLanguage = typeof moreLocale[number]
|
||||
|
||||
// Generate static paths for all supported languages
|
||||
export function getStaticPaths() {
|
||||
return moreLocale.map((lang: SupportedLanguage) => ({ params: { lang } }))
|
||||
}
|
||||
|
||||
export async function GET({ params }: APIContext) {
|
||||
const lang = params.lang as SupportedLanguage
|
||||
|
||||
// Return 404 if language is not supported
|
||||
if (!moreLocale.includes(lang)) {
|
||||
return new Response(null, {
|
||||
status: 404,
|
||||
statusText: 'Not found',
|
||||
})
|
||||
}
|
||||
|
||||
return generateRSS({ lang })
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue