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

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

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

Loading…
Cancel
Save