Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit af32668

Browse files
FuckDoctorsbillyyyyy3320
authored andcommitted
fix: generate paths of frontmatter scope pages properly (fix #39) (#40)
* feat: Support frontmatters scoped path (#39) * fix: frontmatters scopeLayout path * refactor: clean code
1 parent 586bf14 commit af32668

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

examples/frontmatter-classifier/.vuepress/config.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
path: '/tag/',
1313
// Layout of the `entry page`
1414
layout: 'Tags',
15+
scopeLayout: 'FrontmatterClassifier',
1516
},
1617
],
1718
}],

src/node/handleOptions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export function handleOptions(
163163
keys,
164164
map,
165165
scopeLayout,
166-
_handler: curryFrontmatterHandler(id, map),
166+
_handler: curryFrontmatterHandler(id, map, indexPath),
167167
})
168168
}
169169

src/node/index.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ module.exports = (options: BlogPluginOptions, ctx: VuePressContext) => {
131131
/**
132132
* Register pagination
133133
*/
134-
const indexPath = `/${scope}/${key}/`
135-
136134
paginations.push({
137135
classifierType: ClassifierTypeEnum.Frontmatter,
138136
getPaginationPageTitle(index, id, scope) {
@@ -142,7 +140,7 @@ module.exports = (options: BlogPluginOptions, ctx: VuePressContext) => {
142140
ClassifierTypeEnum.Frontmatter,
143141
options.globalPagination,
144142
pagination,
145-
indexPath,
143+
path,
146144
ctx,
147145
keys,
148146
),

src/node/util.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ export interface FrontmatterTempMap {
1414
export function curryFrontmatterHandler(
1515
scope: string,
1616
map: FrontmatterTempMap,
17+
path: string,
1718
): FrontmatterHandler
18-
export function curryFrontmatterHandler(scope, map) {
19+
export function curryFrontmatterHandler(scope, map, path) {
1920
return (key, pageKey) => {
2021
if (key) {
2122
if (!map[key]) {
2223
map[key] = {}
2324
map[key].key = key
2425
map[key].scope = scope
25-
map[key].path = `/${scope}/${key}/`
26+
map[key].path = `${path}${key}/`
2627
map[key].pageKeys = []
2728
}
2829
map[key].pageKeys.push(pageKey)

0 commit comments

Comments
 (0)