mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-17 20:01:33 +02:00
✨ feat: complete language switching functionality and centralized page routing
This commit is contained in:
parent
4651828dd1
commit
05d3a8034b
26 changed files with 253 additions and 146 deletions
|
@ -1,11 +1,19 @@
|
|||
---
|
||||
import { getNextLangUrl } from '@/utils/i18n/lang'
|
||||
import { getNextLangUrl, getPostNextLangUrl } from '@/i18n/lang'
|
||||
import { isPostPage } from '@/i18n/path'
|
||||
|
||||
// 获取当前路径
|
||||
interface Props {
|
||||
supportedLangs?: string[] // 文章支持的语言列表
|
||||
}
|
||||
|
||||
const { supportedLangs = [] } = Astro.props
|
||||
const currentPath = Astro.url.pathname
|
||||
const isPost = isPostPage(currentPath)
|
||||
|
||||
// 直接获取下一个语言的URL
|
||||
const nextUrl = getNextLangUrl(currentPath)
|
||||
// 根据页面类型选择不同的URL获取函数
|
||||
const nextUrl = isPost && supportedLangs.length > 0
|
||||
? getPostNextLangUrl(currentPath, supportedLangs)
|
||||
: getNextLangUrl(currentPath)
|
||||
---
|
||||
|
||||
<a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue