Skip to content

Commit b24c317

Browse files
committed
Revert "perf: improve ssr performance (#1068)" (close: #1140)
This reverts commit 1c2aa08.
1 parent 8735d2c commit b24c317

File tree

1 file changed

+8
-10
lines changed
  • packages/@vuepress/theme-default/util

1 file changed

+8
-10
lines changed

packages/@vuepress/theme-default/util/index.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ export function resolvePage (pages, rawPath, base) {
5858
rawPath = resolvePath(rawPath, base)
5959
}
6060
const path = normalize(rawPath)
61-
if (path in pages) {
62-
return Object.assign({}, pages[path], {
63-
type: 'page',
64-
path: ensureExt(pages[path].path)
65-
})
61+
for (let i = 0; i < pages.length; i++) {
62+
if (normalize(pages[i].regularPath) === path) {
63+
return Object.assign({}, pages[i], {
64+
type: 'page',
65+
path: ensureExt(pages[i].path)
66+
})
67+
}
6668
}
6769
console.error(`[vuepress] No matching page found for sidebar item "${rawPath}"`)
6870
return {}
@@ -126,16 +128,12 @@ export function resolveSidebarItems (page, regularPath, site, localePath) {
126128
}
127129

128130
const sidebarConfig = localeConfig.sidebar || themeConfig.sidebar
129-
const normalizedPagesMap = pages.reduce((map, page) => {
130-
map[normalize(page.regularPath)] = page
131-
return map
132-
}, {})
133131
if (!sidebarConfig) {
134132
return []
135133
} else {
136134
const { base, config } = resolveMatchingConfig(regularPath, sidebarConfig)
137135
return config
138-
? config.map(item => resolveItem(item, normalizedPagesMap, base))
136+
? config.map(item => resolveItem(item, pages, base))
139137
: []
140138
}
141139
}

0 commit comments

Comments
 (0)