mirror of
https://github.com/wahyd4/vuepress.git
synced 2026-08-09 05:16:23 +10:00
21 lines
458 B
JavaScript
21 lines
458 B
JavaScript
export function pathToComponentName (path) {
|
|
if (path.charAt(path.length - 1) === '/') {
|
|
return `page${path.replace(/\//g, '-') + 'index'}`
|
|
} else {
|
|
return `page${path.replace(/\//g, '-').replace(/\.html$/, '')}`
|
|
}
|
|
}
|
|
|
|
export function findPageForPath (pages, path) {
|
|
for (let i = 0; i < pages.length; i++) {
|
|
const page = pages[i]
|
|
if (page.path === path) {
|
|
return page
|
|
}
|
|
}
|
|
return {
|
|
path: '',
|
|
frontmatter: {}
|
|
}
|
|
}
|