This repository was archived by the owner on May 13, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +31
-8
lines changed Expand file tree Collapse file tree 5 files changed +31
-8
lines changed Original file line number Diff line number Diff line change @@ -59,5 +59,28 @@ function getPaginationPageUrl(index) {
5959- For [ frontmatter classifier] ( ../README.md#frontmatter-classifier ) , the ` indexPath ` defaults to ` /${classifier.pid}/${classifier.id} `
6060(e.g. ` /tag/js/ ` )
6161
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.
6285
6386
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ export function handleOptions(
108108 */
109109 paginations . push ( {
110110 classifierType : ClassifierTypeEnum . Directory ,
111- getPaginationPageTitle ( index ) {
111+ getPaginationPageTitle ( index , id ) {
112112 return `Page ${ index + 1 } | ${ id } `
113113 } ,
114114 ...resolvePaginationConfig (
Original file line number Diff line number Diff line change @@ -106,8 +106,8 @@ module.exports = (options: BlogPluginOptions, ctx: VuePressContext) => {
106106
107107 paginations . push ( {
108108 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 } `
111111 } ,
112112 ...resolvePaginationConfig (
113113 ClassifierTypeEnum . Frontmatter ,
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ export type PageSorter = (
1616) => boolean | number
1717
1818export type GetPaginationPageUrl = ( index : number ) => string
19- export type getPaginationPageTitle = ( index : number ) => string
19+ export type GetPaginationPageTitle = ( index : number , id : string , scope : string ) => string
2020
2121/**
2222 * Pagination config options for users.
@@ -45,7 +45,7 @@ export interface PaginationConfig {
4545 /**
4646 * A function to get the title of pagination page dynamically.
4747 */
48- getPaginationPageTitle ?: getPaginationPageTitle ;
48+ getPaginationPageTitle ?: GetPaginationPageTitle ;
4949}
5050
5151export interface PaginationIdentity {
@@ -64,7 +64,7 @@ export interface PaginationIdentity {
6464 */
6565export interface InternalPagination
6666 extends PaginationConfig ,
67- PaginationIdentity {
67+ PaginationIdentity {
6868 /**
6969 * Record which classfier create this pagination.
7070 */
Original file line number Diff line number Diff line change 33 InternalPagination ,
44 PageFilter ,
55 GetPaginationPageUrl ,
6- getPaginationPageTitle ,
6+ GetPaginationPageTitle ,
77 SerializedPagination ,
88} from './interface/Pagination'
99import { logPages } from './util'
@@ -82,7 +82,7 @@ export async function registerPaginations(
8282 permalink : path ,
8383 frontmatter : {
8484 layout,
85- title : ( getPaginationPageTitle as getPaginationPageTitle ) ( index ) ,
85+ title : ( getPaginationPageTitle as GetPaginationPageTitle ) ( index , id , pid ) ,
8686 } ,
8787 meta : {
8888 pid,
You can’t perform that action at this time.
0 commit comments