element-plus/docs/.vitepress/vitepress/composables/lang.ts
Richdro 893e414cab
fix: [el-date-picker] fix DatePicker render error (#7017)
Co-authored-by: RealityBoy <1923740402@qq.com>
2022-08-31 15:43:36 +08:00

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
})
}