2021-09-30 19:26:30 +08:00
|
|
|
import { ensureLang } from '../utils/lang'
|
|
|
|
import navLocale from '../i18n/pages/sidebar.json'
|
|
|
|
|
|
|
|
// Mapping the first sub link to the nav link to avoid 404 error.
|
|
|
|
|
|
|
|
function getNav() {
|
|
|
|
return Object.fromEntries(
|
2021-12-30 19:00:11 +08:00
|
|
|
Object.entries(navLocale).map(([lang, locales]) => {
|
|
|
|
const item: {
|
2021-09-30 19:26:30 +08:00
|
|
|
link: string
|
|
|
|
text: string
|
|
|
|
activeMatch?: string
|
2021-12-30 19:00:11 +08:00
|
|
|
}[] = Object.values(locales).map((item) => ({
|
2021-09-30 19:26:30 +08:00
|
|
|
...item,
|
|
|
|
link: `${ensureLang(lang)}${item.link}`,
|
|
|
|
}))
|
|
|
|
|
2021-12-30 19:00:11 +08:00
|
|
|
return [lang, item]
|
2021-09-30 19:26:30 +08:00
|
|
|
})
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export const nav = getNav()
|