This repository was archived by the owner on May 13, 2024. It is now read-only.
File tree 5 files changed +31
-8
lines changed
5 files changed +31
-8
lines changed Original file line number Diff line number Diff line change @@ -59,5 +59,28 @@ function getPaginationPageUrl(index) {
59
59
- For [ frontmatter classifier] ( ../README.md#frontmatter-classifier ) , the ` indexPath ` defaults to ` /${classifier.pid}/${classifier.id} `
60
60
(e.g. ` /tag/js/ ` )
61
61
62
+ ## getPaginationPageTitle
63
+
64
+ - Type: function
65
+ - Default: ` See Below `
66
+
67
+ A function to get the title of pagination page dynamically:
68
+
69
+ ``` js
70
+ // directories
71
+ function getPaginationPageTitle (index , id ) {
72
+ return ` Page ${ index + 1 } | ${ id} `
73
+ }
74
+
75
+ // frontmatters
76
+ function getPaginationPageTitle (index , id , scope ) {
77
+ return ` Page ${ index + 1 } - ${ id} | ${ scope} `
78
+ }
79
+ ```
80
+
81
+ There are three args to help you customize your title:
82
+ - ` index ` is the index of pages.
83
+ - ` id ` is the id in the [ config] ( ../config/#id ) .
84
+ - ` scope ` is the [ key] ( ../config/#keys ) while configuring frontmatters or same as ` id ` while configuring directories.
62
85
63
86
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ export function handleOptions(
108
108
*/
109
109
paginations . push ( {
110
110
classifierType : ClassifierTypeEnum . Directory ,
111
- getPaginationPageTitle ( index ) {
111
+ getPaginationPageTitle ( index , id ) {
112
112
return `Page ${ index + 1 } | ${ id } `
113
113
} ,
114
114
...resolvePaginationConfig (
Original file line number Diff line number Diff line change @@ -106,8 +106,8 @@ module.exports = (options: BlogPluginOptions, ctx: VuePressContext) => {
106
106
107
107
paginations . push ( {
108
108
classifierType : ClassifierTypeEnum . Frontmatter ,
109
- getPaginationPageTitle ( index ) {
110
- return `Page ${ index + 1 } - ${ key } | ${ scope } `
109
+ getPaginationPageTitle ( index , id , scope ) {
110
+ return `Page ${ index + 1 } - ${ id } | ${ scope } `
111
111
} ,
112
112
...resolvePaginationConfig (
113
113
ClassifierTypeEnum . Frontmatter ,
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ export type PageSorter = (
16
16
) => boolean | number
17
17
18
18
export type GetPaginationPageUrl = ( index : number ) => string
19
- export type getPaginationPageTitle = ( index : number ) => string
19
+ export type GetPaginationPageTitle = ( index : number , id : string , scope : string ) => string
20
20
21
21
/**
22
22
* Pagination config options for users.
@@ -45,7 +45,7 @@ export interface PaginationConfig {
45
45
/**
46
46
* A function to get the title of pagination page dynamically.
47
47
*/
48
- getPaginationPageTitle ?: getPaginationPageTitle ;
48
+ getPaginationPageTitle ?: GetPaginationPageTitle ;
49
49
}
50
50
51
51
export interface PaginationIdentity {
@@ -64,7 +64,7 @@ export interface PaginationIdentity {
64
64
*/
65
65
export interface InternalPagination
66
66
extends PaginationConfig ,
67
- PaginationIdentity {
67
+ PaginationIdentity {
68
68
/**
69
69
* Record which classfier create this pagination.
70
70
*/
Original file line number Diff line number Diff line change 3
3
InternalPagination ,
4
4
PageFilter ,
5
5
GetPaginationPageUrl ,
6
- getPaginationPageTitle ,
6
+ GetPaginationPageTitle ,
7
7
SerializedPagination ,
8
8
} from './interface/Pagination'
9
9
import { logPages } from './util'
@@ -82,7 +82,7 @@ export async function registerPaginations(
82
82
permalink : path ,
83
83
frontmatter : {
84
84
layout,
85
- title : ( getPaginationPageTitle as getPaginationPageTitle ) ( index ) ,
85
+ title : ( getPaginationPageTitle as GetPaginationPageTitle ) ( index , id , pid ) ,
86
86
} ,
87
87
meta : {
88
88
pid,
You can’t perform that action at this time.
0 commit comments