-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: improve ssr performance #1068
Changes from 1 commit
c4e6d0a
4f5e3a1
5d606fd
37b7d55
f9f08b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,13 +58,11 @@ export function resolvePage (pages, rawPath, base) { | |
rawPath = resolvePath(rawPath, base) | ||
} | ||
const path = normalize(rawPath) | ||
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) | ||
}) | ||
} | ||
if (path in pages) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changes the function signature but doesn't update all the callers. resolvePage is also called from the default theme. See vuepress/packages/@vuepress/theme-default/components/Page.vue computed.prev. which is now broken and gives an error when trying to use frontmatter prev / next links. See #1140 for a primitive fix. Thanks. |
||
return Object.assign({}, pages[path], { | ||
type: 'page', | ||
path: ensureExt(pages[path].path) | ||
}) | ||
} | ||
console.error(`[vuepress] No matching page found for sidebar item "${rawPath}"`) | ||
return {} | ||
|
@@ -128,12 +126,14 @@ export function resolveSidebarItems (page, regularPath, site, localePath) { | |
} | ||
|
||
const sidebarConfig = localeConfig.sidebar || themeConfig.sidebar | ||
let normalizedPagesMap = {} | ||
pages.forEach(page => normalizedPagesMap[normalize(page.regularPath)] = page); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe following style would be more refreshing: const normalizedPagesMap = pages.reduce((map, page) => map[normalize(page.regularPath)] = page, {}) |
||
if (!sidebarConfig) { | ||
return [] | ||
} else { | ||
const { base, config } = resolveMatchingConfig(regularPath, sidebarConfig) | ||
return config | ||
? config.map(item => resolveItem(item, pages, base)) | ||
? config.map(item => resolveItem(item, normalizedPagesMap, base)) | ||
: [] | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this file has been removed for now since we deprecated smooth scroll.