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

Commit

Permalink
fix: generate paths of frontmatter scope pages properly (fix #39) (#40)
Browse files Browse the repository at this point in the history
* feat: Support frontmatters scoped path (#39)

* fix: frontmatters scopeLayout path

* refactor: clean code
  • Loading branch information
FuckDoctors authored and billyyyyy3320 committed Dec 7, 2019
1 parent 586bf14 commit af32668
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions examples/frontmatter-classifier/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
path: '/tag/',
// Layout of the `entry page`
layout: 'Tags',
scopeLayout: 'FrontmatterClassifier',
},
],
}],
Expand Down
2 changes: 1 addition & 1 deletion src/node/handleOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export function handleOptions(
keys,
map,
scopeLayout,
_handler: curryFrontmatterHandler(id, map),
_handler: curryFrontmatterHandler(id, map, indexPath),
})
}

Expand Down
4 changes: 1 addition & 3 deletions src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ module.exports = (options: BlogPluginOptions, ctx: VuePressContext) => {
/**
* Register pagination
*/
const indexPath = `/${scope}/${key}/`

paginations.push({
classifierType: ClassifierTypeEnum.Frontmatter,
getPaginationPageTitle(index, id, scope) {
Expand All @@ -142,7 +140,7 @@ module.exports = (options: BlogPluginOptions, ctx: VuePressContext) => {
ClassifierTypeEnum.Frontmatter,
options.globalPagination,
pagination,
indexPath,
path,
ctx,
keys,
),
Expand Down
5 changes: 3 additions & 2 deletions src/node/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ export interface FrontmatterTempMap {
export function curryFrontmatterHandler(
scope: string,
map: FrontmatterTempMap,
path: string,
): FrontmatterHandler
export function curryFrontmatterHandler(scope, map) {
export function curryFrontmatterHandler(scope, map, path) {
return (key, pageKey) => {
if (key) {
if (!map[key]) {
map[key] = {}
map[key].key = key
map[key].scope = scope
map[key].path = `/${scope}/${key}/`
map[key].path = `${path}${key}/`
map[key].pageKeys = []
}
map[key].pageKeys.push(pageKey)
Expand Down

0 comments on commit af32668

Please sign in to comment.