diff --git a/.changeset/slimy-vans-rush.md b/.changeset/slimy-vans-rush.md new file mode 100644 index 00000000000..009d3a8cf0d --- /dev/null +++ b/.changeset/slimy-vans-rush.md @@ -0,0 +1,5 @@ +--- +'nextra-theme-docs': patch +--- + +Update the `backToTop` option in the docs theme configuration to support i18n diff --git a/.changeset/wild-windows-grow.md b/.changeset/wild-windows-grow.md new file mode 100644 index 00000000000..b2a1bbe6216 --- /dev/null +++ b/.changeset/wild-windows-grow.md @@ -0,0 +1,5 @@ +--- +'nextra-theme-docs': minor +--- + +keep `loading`, `placeholder` and `themeSwitch.useOptions` default theme options only for `en` lang diff --git a/docs/next-env.d.ts b/docs/next-env.d.ts index 4f11a03dc6c..a4a7b3f5cfa 100644 --- a/docs/next-env.d.ts +++ b/docs/next-env.d.ts @@ -2,4 +2,4 @@ /// // NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. +// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information. diff --git a/docs/pages/docs/docs-theme/theme-configuration.mdx b/docs/pages/docs/docs-theme/theme-configuration.mdx index 0b7836a3f9a..43b3f777602 100644 --- a/docs/pages/docs/docs-theme/theme-configuration.mdx +++ b/docs/pages/docs/docs-theme/theme-configuration.mdx @@ -534,7 +534,11 @@ navigating between headings. 'React.ReactNode | React.FC', 'Title of the TOC sidebar. By default it’s “On This Page”.' ], - ['toc.backToTop', 'boolean', 'Add `Scroll to top` link.'] + [ + 'toc.backToTop', + 'React.ReactNode | React.FC', + 'Text of `Scroll to top` button.' + ] ]} /> diff --git a/examples/swr-site/next-env.d.ts b/examples/swr-site/next-env.d.ts index fd36f9494e2..725dd6f2451 100644 --- a/examples/swr-site/next-env.d.ts +++ b/examples/swr-site/next-env.d.ts @@ -3,4 +3,4 @@ /// // NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. +// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information. diff --git a/examples/swr-site/theme.config.tsx b/examples/swr-site/theme.config.tsx index 707c9ca5f3c..03913b5c014 100644 --- a/examples/swr-site/theme.config.tsx +++ b/examples/swr-site/theme.config.tsx @@ -190,6 +190,14 @@ const config: DocsThemeConfig = { toggleButton: true }, toc: { + backToTop: function BackToTop() { + const { locale } = useRouter() + return { + en: 'Scroll to top', + es: 'Desplazarse hacia arriba', + ru: 'Перейти наверх' + }[locale!] + }, extraContent: ( placeholder cat ), diff --git a/packages/nextra-theme-docs/src/components/back-to-top.tsx b/packages/nextra-theme-docs/src/components/back-to-top.tsx index 58d45a87028..9dd517aefef 100644 --- a/packages/nextra-theme-docs/src/components/back-to-top.tsx +++ b/packages/nextra-theme-docs/src/components/back-to-top.tsx @@ -1,7 +1,7 @@ import cn from 'clsx' import { Button } from 'nextra/components' import { ArrowRightIcon } from 'nextra/icons' -import type { ComponentProps, ReactElement } from 'react' +import type { ComponentProps, ReactElement, ReactNode } from 'react' const SCROLL_TO_OPTIONS = { top: 0, behavior: 'smooth' } as const @@ -18,9 +18,11 @@ const scrollToTop: ComponentProps<'button'>['onClick'] = event => { } export function BackToTop({ + children, className, hidden }: { + children: ReactNode className?: string hidden: boolean }): ReactElement { @@ -38,7 +40,7 @@ export function BackToTop({ ) } > - Scroll to top + {children}