refactor: optimize all i18n route pages

This commit is contained in:
radishzzz 2025-03-17 18:15:17 +00:00
parent 0888b59c5f
commit 473b13d0ab
8 changed files with 125 additions and 133 deletions

View file

@ -2,6 +2,18 @@ import { defaultLocale, moreLocales } from '@/config'
import { getLangFromPath, getNextGlobalLang } from '@/i18n/lang'
import { cleanPath } from '@/utils/page'
/**
* Get path to tag page with language support
* @param tagName Tag name
* @param lang Current language code
* @returns Path to tag page
*/
export function getTagPath(tagName: string, lang: string): string {
return lang === defaultLocale
? `/tags/${tagName}/`
: `/${lang}/tags/${tagName}/`
}
// Generates a localized path based on current language
export function getLocalizedPath(path: string, currentLang?: string) {
const clean = cleanPath(path)