Skip to content

Commit 09a4fdc

Browse files
committedAug 4, 2023
feat(theme): allow customizing prev/next text from config file
closes #1373
1 parent 69251b7 commit 09a4fdc

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed
 

‎src/client/theme-default/composables/prev-next.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export function usePrevNext() {
3131
? frontmatter.value.prev
3232
: typeof frontmatter.value.prev === 'object'
3333
? frontmatter.value.prev.text
34-
: undefined) ?? candidates[index - 1]?.text,
34+
: undefined) ??
35+
candidates[index - 1]?.docFooterText ??
36+
candidates[index - 1]?.text,
3537
link:
3638
(typeof frontmatter.value.prev === 'object'
3739
? frontmatter.value.prev.link
@@ -45,7 +47,9 @@ export function usePrevNext() {
4547
? frontmatter.value.next
4648
: typeof frontmatter.value.next === 'object'
4749
? frontmatter.value.next.text
48-
: undefined) ?? candidates[index + 1]?.text,
50+
: undefined) ??
51+
candidates[index + 1]?.docFooterText ??
52+
candidates[index + 1]?.text,
4953
link:
5054
(typeof frontmatter.value.next === 'object'
5155
? frontmatter.value.next.link

‎src/client/theme-default/support/sidebar.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { isActive } from '../../shared'
55
export interface SidebarLink {
66
text: string
77
link: string
8+
docFooterText?: string
89
}
910

1011
type SidebarItem = DefaultTheme.SidebarItem
@@ -71,7 +72,11 @@ export function getFlatSideBarLinks(sidebar: SidebarItem[]): SidebarLink[] {
7172
function recursivelyExtractLinks(items: SidebarItem[]) {
7273
for (const item of items) {
7374
if (item.text && item.link) {
74-
links.push({ text: item.text, link: item.link })
75+
links.push({
76+
text: item.text,
77+
link: item.link,
78+
docFooterText: item.docFooterText
79+
})
7580
}
7681

7782
if (item.items) {

‎types/default-theme.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ export namespace DefaultTheme {
229229
* Base path for the children items.
230230
*/
231231
base?: string
232+
233+
/**
234+
* Customize text that appears on the footer of previous/next page.
235+
*/
236+
docFooterText?: string
232237
}
233238

234239
/**

0 commit comments

Comments
 (0)
Please sign in to comment.