feat(theme): allow prev/next links to be disabled globally (#2317)

Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
pull/1844/head
donggua 2 years ago committed by GitHub
parent 90478b36cd
commit 29a9647ee9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -351,7 +351,7 @@ Learn more in [Default Theme: Carbon Ads](./default-theme-carbon-ads)
- Type: `DocFooter`
Can be used to customize text appearing above previous and next links. Helpful if not writing docs in English.
Can be used to customize text appearing above previous and next links. Helpful if not writing docs in English. Also can be used to disable prev/next links globally. If you want to selectively enable/disable prev/next links, you can use [frontmatter](./default-theme-prev-next-links).
```js
export default {
@ -366,8 +366,8 @@ export default {
```ts
export interface DocFooter {
prev?: string
next?: string
prev?: string | false
next?: string | false
}
```

@ -14,9 +14,16 @@ export function usePrevNext() {
return isActive(page.value.relativePath, link.link)
})
return {
prev:
const hidePrev =
(theme.value.docFooter?.prev === false && !frontmatter.value.prev) ||
frontmatter.value.prev === false
const hideNext =
(theme.value.docFooter?.next === false && !frontmatter.value.next) ||
frontmatter.value.next === false
return {
prev: hidePrev
? undefined
: {
text:
@ -30,8 +37,7 @@ export function usePrevNext() {
? frontmatter.value.prev.link
: undefined) ?? candidates[index - 1]?.link
},
next:
frontmatter.value.next === false
next: hideNext
? undefined
: {
text:

@ -232,18 +232,18 @@ export namespace DefaultTheme {
export interface DocFooter {
/**
* Custom label for previous page button.
* Custom label for previous page button. Can be set to `false` to disable.
*
* @default 'Previous page'
*/
prev?: string
prev?: string | boolean
/**
* Custom label for next page button.
* Custom label for next page button. Can be set to `false` to disable.
*
* @default 'Next page'
*/
next?: string
next?: string | boolean
}
// social link ---------------------------------------------------------------

Loading…
Cancel
Save