fix: switch language bug. #106

pull/104/head
zuofenghua 5 years ago
parent e937fc0f1a
commit 944bf801b7

@ -88,13 +88,11 @@ export default {
}
})
const navData = computed(() => {
return siteDataByRoute.value.themeConfig.nav
})
return {
navData:
process.env.NODE_ENV === 'production'
? // navbar items do not change in production
siteDataByRoute.value.themeConfig.nav
: // use computed in dev for hot reload
computed(() => siteDataByRoute.value.themeConfig.nav),
navData,
repoInfo,
localeCandidates
}

@ -1,4 +1,5 @@
import { SiteData } from '../../types/shared'
const inBrowser = typeof window !== 'undefined'
function findMatchRoot(route: string, roots: string[]) {
// first match to the routes with the most deep level.
@ -27,6 +28,12 @@ function resolveLocales<T>(
// this merges the locales data to the main data by the route
export function resolveSiteDataByRoute(siteData: SiteData, route: string) {
if (inBrowser) {
const siteBaseWithoutSuffix = siteData.base.endsWith('/')
? siteData.base.slice(0, -1)
: siteData.base
route = route.slice(siteBaseWithoutSuffix.length)
}
const localeData = resolveLocales(siteData.locales || {}, route) || {}
const localeThemeConfig =
resolveLocales<any>(

Loading…
Cancel
Save