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` - 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 ```js
export default { export default {
@ -366,8 +366,8 @@ export default {
```ts ```ts
export interface DocFooter { export interface DocFooter {
prev?: string prev?: string | false
next?: string next?: string | false
} }
``` ```

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

@ -232,18 +232,18 @@ export namespace DefaultTheme {
export interface DocFooter { 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' * @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' * @default 'Next page'
*/ */
next?: string next?: string | boolean
} }
// social link --------------------------------------------------------------- // social link ---------------------------------------------------------------

Loading…
Cancel
Save