chore: update detail

This commit is contained in:
radishzzz 2025-03-14 13:45:50 +00:00
parent 91d27dd2ba
commit ca1abd28c1
10 changed files with 63 additions and 61 deletions

View file

@ -154,19 +154,3 @@ export function getPostNextLangUrl(currentPath: string, supportedLangs: string[]
// 构建下一个语言的URL
return buildNextLangUrl(currentPath, currentLang, nextLang)
}
/**
* Get the language code of Waline
* @param currentPath Current page path
* @param defaultLocale Default language
* @returns Corresponding Waline language code
*/
export function getWalineLang(currentPath: string, defaultLocale: string): string {
// Extract language code from path
const pathLang = Object.keys(walineLocaleMap).find(code =>
currentPath.startsWith(`/${code}/`),
)
// Return found path language or default language
const lang = pathLang || defaultLocale
return walineLocaleMap[lang as keyof typeof walineLocaleMap]
}

View file

@ -27,17 +27,14 @@ export function isHomePage(path: string) {
const clean = cleanPath(path)
return clean === '' || moreLocales.includes(clean)
}
export function isPostPage(path: string) {
const clean = cleanPath(path)
return clean.startsWith('posts') || moreLocales.some(lang => clean.startsWith(`${lang}/posts`))
}
export function isTagPage(path: string) {
const clean = cleanPath(path)
return clean.startsWith('tags') || moreLocales.some(lang => clean.startsWith(`${lang}/tags`))
}
export function isAboutPage(path: string) {
const clean = cleanPath(path)
return clean.startsWith('about') || moreLocales.some(lang => clean.startsWith(`${lang}/about`))