feat(theme): allow customizing prev/next text from config file

closes #1373
pull/2736/head
Divyansh Singh 1 year ago
parent 69251b7484
commit 09a4fdc9b8

@ -31,7 +31,9 @@ export function usePrevNext() {
? frontmatter.value.prev
: typeof frontmatter.value.prev === 'object'
? frontmatter.value.prev.text
: undefined) ?? candidates[index - 1]?.text,
: undefined) ??
candidates[index - 1]?.docFooterText ??
candidates[index - 1]?.text,
link:
(typeof frontmatter.value.prev === 'object'
? frontmatter.value.prev.link
@ -45,7 +47,9 @@ export function usePrevNext() {
? frontmatter.value.next
: typeof frontmatter.value.next === 'object'
? frontmatter.value.next.text
: undefined) ?? candidates[index + 1]?.text,
: undefined) ??
candidates[index + 1]?.docFooterText ??
candidates[index + 1]?.text,
link:
(typeof frontmatter.value.next === 'object'
? frontmatter.value.next.link

@ -5,6 +5,7 @@ import { isActive } from '../../shared'
export interface SidebarLink {
text: string
link: string
docFooterText?: string
}
type SidebarItem = DefaultTheme.SidebarItem
@ -71,7 +72,11 @@ export function getFlatSideBarLinks(sidebar: SidebarItem[]): SidebarLink[] {
function recursivelyExtractLinks(items: SidebarItem[]) {
for (const item of items) {
if (item.text && item.link) {
links.push({ text: item.text, link: item.link })
links.push({
text: item.text,
link: item.link,
docFooterText: item.docFooterText
})
}
if (item.items) {

@ -229,6 +229,11 @@ export namespace DefaultTheme {
* Base path for the children items.
*/
base?: string
/**
* Customize text that appears on the footer of previous/next page.
*/
docFooterText?: string
}
/**

Loading…
Cancel
Save