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

fix: generate pagination title correctly (fix: #41) #42

Merged
merged 2 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
9 changes: 7 additions & 2 deletions docs/pagination/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ A function to get the title of pagination page dynamically:
```js
// directories
function getPaginationPageTitle (index, id) {
return `Page ${index + 1} | ${id}`
return `Page ${index + 2} | ${id}`
}

// frontmatters
function getPaginationPageTitle (index, id, scope) {
return `Page ${index + 1} - ${id} | ${scope}`
return `Page ${index + 2} - ${id} | ${scope}`
}
```

Expand All @@ -83,4 +83,9 @@ There are three args to help you customize your title:
- `id` is the id in the [config](../config/#id).
- `scope` is the [key](../config/#keys) while configuring frontmatters or same as `id` while configuring directories.

::: tip TIP
`${index + 2}`: why `+2`?

Plus 1 since index starts at 0. <br>
Plus another 1 since the index page won't show page number.
:::
2 changes: 1 addition & 1 deletion src/node/handleOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function handleOptions(
paginations.push({
classifierType: ClassifierTypeEnum.Directory,
getPaginationPageTitle(index, id) {
return `Page ${index + 1} | ${id}`
return `Page ${index + 2} | ${id}`
},
...resolvePaginationConfig(
ClassifierTypeEnum.Directory,
Expand Down
2 changes: 1 addition & 1 deletion src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ module.exports = (options: BlogPluginOptions, ctx: VuePressContext) => {
paginations.push({
classifierType: ClassifierTypeEnum.Frontmatter,
getPaginationPageTitle(index, id, scope) {
return `Page ${index + 1} - ${id} | ${scope}`
return `Page ${index + 2} - ${id} | ${scope}`
},
...resolvePaginationConfig(
ClassifierTypeEnum.Frontmatter,
Expand Down