feat: enhance internationalization support with dynamic routing

This commit is contained in:
radishzzz 2025-01-18 02:25:00 +00:00
parent d6c98880d3
commit 8c19d26cfd
12 changed files with 199 additions and 87 deletions

View file

@ -1,13 +1,16 @@
---
import { themeConfig } from '@/config'
import Layout from '@/layouts/Layout.astro'
import { getCollection } from 'astro:content'
export async function getStaticPaths() {
const posts = await getCollection('posts')
return posts.map(post => ({
params: { slug: post.slug },
props: { post },
}))
return themeConfig.global.moreLocale.flatMap(lang =>
posts.map(post => ({
params: { lang, slug: post.slug },
props: { post },
})),
)
}
const { post } = Astro.props