Skip to content

Commit

Permalink
Revert "perf: improve ssr performance (#1068)" (close: #1140)
Browse files Browse the repository at this point in the history
This reverts commit 1c2aa08.
  • Loading branch information
ulivz committed Jan 15, 2019
1 parent 8735d2c commit b24c317
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions packages/@vuepress/theme-default/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ export function resolvePage (pages, rawPath, base) {
rawPath = resolvePath(rawPath, base)
}
const path = normalize(rawPath)
if (path in pages) {
return Object.assign({}, pages[path], {
type: 'page',
path: ensureExt(pages[path].path)
})
for (let i = 0; i < pages.length; i++) {
if (normalize(pages[i].regularPath) === path) {
return Object.assign({}, pages[i], {
type: 'page',
path: ensureExt(pages[i].path)
})
}
}
console.error(`[vuepress] No matching page found for sidebar item "${rawPath}"`)
return {}
Expand Down Expand Up @@ -126,16 +128,12 @@ export function resolveSidebarItems (page, regularPath, site, localePath) {
}

const sidebarConfig = localeConfig.sidebar || themeConfig.sidebar
const normalizedPagesMap = pages.reduce((map, page) => {
map[normalize(page.regularPath)] = page
return map
}, {})
if (!sidebarConfig) {
return []
} else {
const { base, config } = resolveMatchingConfig(regularPath, sidebarConfig)
return config
? config.map(item => resolveItem(item, normalizedPagesMap, base))
? config.map(item => resolveItem(item, pages, base))
: []
}
}
Expand Down

0 comments on commit b24c317

Please sign in to comment.