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

feat: generate paths of frontmatter scope pages properly (fix #39) #40

Merged
merged 3 commits into from
Dec 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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