mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 19:51:07 +02:00
optimize: rss generation
This commit is contained in:
parent
54902da6dd
commit
ff59dc1a7c
6 changed files with 16 additions and 23 deletions
|
@ -1,20 +1,16 @@
|
|||
import type { APIContext } from 'astro'
|
||||
import themeConfig from '@/config'
|
||||
import { getMultiLangRoutes } from '@/i18n/route'
|
||||
import { moreLocales } from '@/i18n/config'
|
||||
import { generateRSS } from '@/utils/rss'
|
||||
|
||||
const { moreLocales } = themeConfig.global
|
||||
|
||||
// Type for supported non-default languages
|
||||
type SupportedLanguage = typeof moreLocales[number]
|
||||
|
||||
// Generate static paths for all supported languages
|
||||
export function getStaticPaths() {
|
||||
return getMultiLangRoutes()
|
||||
return moreLocales.map(lang => ({
|
||||
params: { lang },
|
||||
}))
|
||||
}
|
||||
|
||||
export async function GET({ params }: APIContext) {
|
||||
const lang = params.lang as SupportedLanguage
|
||||
const lang = params.lang as typeof moreLocales[number]
|
||||
|
||||
// Return 404 if language is not supported
|
||||
if (!moreLocales.includes(lang)) {
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
import type { APIContext } from 'astro'
|
||||
import themeConfig from '@/config'
|
||||
import { getMultiLangRoutes } from '@/i18n/route'
|
||||
import { moreLocales } from '@/i18n/config'
|
||||
import { generateRSS } from '@/utils/rss'
|
||||
|
||||
const { moreLocales } = themeConfig.global
|
||||
|
||||
// Type for supported non-default languages
|
||||
type SupportedLanguage = typeof moreLocales[number]
|
||||
|
||||
// Generate static paths for all supported languages
|
||||
export function getStaticPaths() {
|
||||
return getMultiLangRoutes()
|
||||
return moreLocales.map(lang => ({
|
||||
params: { lang },
|
||||
}))
|
||||
}
|
||||
|
||||
export async function GET({ params }: APIContext) {
|
||||
const lang = params.lang as SupportedLanguage
|
||||
const lang = params.lang as typeof moreLocales[number]
|
||||
|
||||
// Return 404 if language is not supported
|
||||
if (!moreLocales.includes(lang)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue