Skip to content

Commit

Permalink
feat(theme): allow customizing prev/next text from config file
Browse files Browse the repository at this point in the history
closes #1373
  • Loading branch information
brc-dd committed Aug 4, 2023
1 parent 69251b7 commit 09a4fdc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/client/theme-default/composables/prev-next.ts
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/client/theme-default/support/sidebar.ts
Expand Up @@ -5,6 +5,7 @@ import { isActive } from '../../shared'
export interface SidebarLink {
text: string
link: string
docFooterText?: string
}

type SidebarItem = DefaultTheme.SidebarItem
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions types/default-theme.d.ts
Expand Up @@ -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
}

/**
Expand Down

0 comments on commit 09a4fdc

Please sign in to comment.