mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 19:51:07 +02:00
refactor: optimize all i18n route pages
This commit is contained in:
parent
0888b59c5f
commit
473b13d0ab
8 changed files with 125 additions and 133 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue