mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-02 11:17:46 +08:00
893e414cab
Co-authored-by: RealityBoy <1923740402@qq.com>
20 lines
451 B
TypeScript
20 lines
451 B
TypeScript
import { computed } from 'vue'
|
|
import { useRoute } from 'vitepress'
|
|
import { defaultLang } from '../constant'
|
|
|
|
export const useLang = () => {
|
|
const route = useRoute()
|
|
return computed(() => {
|
|
// the first part of the first slash
|
|
const path = route.data?.relativePath
|
|
let lang: string
|
|
|
|
if (path?.includes('/')) {
|
|
lang = path.split('/').shift()! || defaultLang
|
|
} else {
|
|
lang = defaultLang
|
|
}
|
|
return lang
|
|
})
|
|
}
|