[Feature request] Automatically prepend all paths in navbar
and sidebar
with root path of locale
#128
-
Clear and concise description of the problemAs per #110, all paths in the theme configuration must be hardcoded. This makes it slightly difficult to manage several translated locales as all of them must be manually handled by the end user. Suggested solutionSince the i18n page on VuePress and default theme locale documentation both suggest that a static path has to be passed anyway, I feel that it would make sense if the configurations themselves do not need to have the locale path hardcoded for For instance, if a user defines: sidebar: {
'/get-started.html': [
... then it can be interpreted as AlternativeAt the moment, it is also impossible to use a variable for items in const locale = 'zh_CN';
sidebar: {
`/${locale}/get-started.html`: [
... It would be nice if this was supported, as it would be easier to enable languages by just changing Additional contextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
CHATGPT or google is a good thing. To use variable on property, you need a square bracket around it. const key = "class"
const value = "dark"
const attr = {
[key]: value
} Also, |
Beta Was this translation helpful? Give feedback.
-
Obviously, I have no responsibility to teach you JavaScript basics here. So closing this one. |
Beta Was this translation helpful? Give feedback.
-
By the way, If you write the grammar well, your alternative is our recommended approach about reusing navbar and sidebar across the locates. You can create a generator function for your navbar and sidebar , and reuse it. E.g.: const getNavbar = (locales: string) => [
`${locales}`,
`${locales}guide/`,
`${locales}about`,
] |
Beta Was this translation helpful? Give feedback.
By the way, If you write the grammar well, your alternative is our recommended approach about reusing navbar and sidebar across the locates. You can create a generator function for your navbar and sidebar , and reuse it.
E.g.: