From ef306a19696e075f7b9e6598ed0d35cc399bb0ac Mon Sep 17 00:00:00 2001 From: Fuma Nama Date: Sat, 28 Dec 2024 09:44:56 +0800 Subject: [PATCH 1/8] Docs: improve guide --- .../content/docs/ui/internationalization.mdx | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/apps/docs/content/docs/ui/internationalization.mdx b/apps/docs/content/docs/ui/internationalization.mdx index 891c76ffb..c17160887 100644 --- a/apps/docs/content/docs/ui/internationalization.mdx +++ b/apps/docs/content/docs/ui/internationalization.mdx @@ -68,20 +68,20 @@ See [Middleware](/docs/headless/internationalization#middleware) for customisabl ### Routing Create a dynamic route `/app/[lang]`, and move all special files from `/app` to -the folder. +the folder (e.g. `page.tsx`, `layout.tsx`). A `I18nProvider` is needed for localization. Wrap the root provider inside your I18n provider, and provide available languages & translations to it. Note that only English translations are provided by default. -```tsx +```tsx title="app/[lang]/layout.tsx" import { RootProvider } from 'fumadocs-ui/provider'; import { I18nProvider, type Translations } from 'fumadocs-ui/i18n'; -const cn: Translations = { +const cn: Partial = { search: 'Translated Content', - // other props + // other translations }; // available languages that will be displayed on UI @@ -104,16 +104,18 @@ export default async function RootLayout({ params: Promise<{ lang: string }>; children: React.ReactNode; }) { + const lang = (await params).lang; + return ( - + {children} @@ -126,7 +128,7 @@ export default async function RootLayout({ ### Source -Update the usages to your source to include a locale code: +Update the references to your `source` object to include a locale code: ```ts import { source } from '@/lib/source'; @@ -141,9 +143,10 @@ source.getPage(params.slug, params.lang); source.getPages(params.lang); ``` -like: +In code editors, you can click on the variable in `lib/source.ts` to quickly find its references. +For example, it looks like this for docs layout: -```tsx title="app/[lang]/layout.tsx" +```tsx title="app/[lang]/docs/layout.tsx" import { source } from '@/lib/source'; import { DocsLayout } from 'fumadocs-ui/docs'; import type { ReactNode } from 'react'; From 193127923284ff15a637f131f1e1dcd4a6de812e Mon Sep 17 00:00:00 2001 From: Rodrigo Pombo Date: Sat, 28 Dec 2024 15:59:24 +0100 Subject: [PATCH 2/8] Add dynamic-link export --- packages/core/package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core/package.json b/packages/core/package.json index b54384be3..2fb2a1212 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -60,6 +60,10 @@ "import": "./dist/link.js", "types": "./dist/link.d.ts" }, + "./dynamic-link": { + "import": "./dist/dynamic-link.js", + "types": "./dist/dynamic-link.d.ts" + }, "./mdx-plugins": { "import": "./dist/mdx-plugins/index.js", "types": "./dist/mdx-plugins/index.d.ts" From 5474343f1703ad3650f2cf165bbfe2c361252ded Mon Sep 17 00:00:00 2001 From: Rodrigo Pombo Date: Sat, 28 Dec 2024 16:00:53 +0100 Subject: [PATCH 3/8] Create slimy-ads-deny.md --- .changeset/slimy-ads-deny.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/slimy-ads-deny.md diff --git a/.changeset/slimy-ads-deny.md b/.changeset/slimy-ads-deny.md new file mode 100644 index 000000000..935826139 --- /dev/null +++ b/.changeset/slimy-ads-deny.md @@ -0,0 +1,5 @@ +--- +"fumadocs-core": patch +--- + +Export dynamic-link From 61f0e3ad7628463a7d21face0babce892f814796 Mon Sep 17 00:00:00 2001 From: Fuma Nama <76240755+fuma-nama@users.noreply.github.com> Date: Sat, 28 Dec 2024 23:46:33 +0800 Subject: [PATCH 4/8] Version Packages (#1200) --- .changeset/slimy-ads-deny.md | 5 ----- packages/core/CHANGELOG.md | 6 ++++++ packages/core/package.json | 2 +- packages/create-app/CHANGELOG.md | 2 ++ packages/create-app/package.json | 2 +- packages/openapi/CHANGELOG.md | 8 ++++++++ packages/openapi/package.json | 2 +- packages/ui/CHANGELOG.md | 7 +++++++ packages/ui/package.json | 2 +- 9 files changed, 27 insertions(+), 9 deletions(-) delete mode 100644 .changeset/slimy-ads-deny.md diff --git a/.changeset/slimy-ads-deny.md b/.changeset/slimy-ads-deny.md deleted file mode 100644 index 935826139..000000000 --- a/.changeset/slimy-ads-deny.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"fumadocs-core": patch ---- - -Export dynamic-link diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 4590856c3..ac8f0da72 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,11 @@ # next-docs-zeta +## 14.6.7 + +### Patch Changes + +- 5474343: Export dynamic-link + ## 14.6.6 ## 14.6.5 diff --git a/packages/core/package.json b/packages/core/package.json index 2fb2a1212..87330047a 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "fumadocs-core", - "version": "14.6.6", + "version": "14.6.7", "description": "The library for building a documentation website in Next.js", "keywords": [ "NextJs", diff --git a/packages/create-app/CHANGELOG.md b/packages/create-app/CHANGELOG.md index 77ff7fc9b..fc05ead48 100644 --- a/packages/create-app/CHANGELOG.md +++ b/packages/create-app/CHANGELOG.md @@ -1,5 +1,7 @@ # create-next-docs-app +## 14.6.7 + ## 14.6.6 ## 14.6.5 diff --git a/packages/create-app/package.json b/packages/create-app/package.json index 85aefa496..d3fa16174 100644 --- a/packages/create-app/package.json +++ b/packages/create-app/package.json @@ -1,6 +1,6 @@ { "name": "create-fumadocs-app", - "version": "14.6.6", + "version": "14.6.7", "description": "Create a new documentation site with Fumadocs", "keywords": [ "NextJs", diff --git a/packages/openapi/CHANGELOG.md b/packages/openapi/CHANGELOG.md index 02fc6bf22..576ba8134 100644 --- a/packages/openapi/CHANGELOG.md +++ b/packages/openapi/CHANGELOG.md @@ -1,5 +1,13 @@ # @fuma-docs/openapi +## 5.10.5 + +### Patch Changes + +- Updated dependencies [5474343] + - fumadocs-core@14.6.7 + - fumadocs-ui@14.6.7 + ## 5.10.4 ### Patch Changes diff --git a/packages/openapi/package.json b/packages/openapi/package.json index 40ad2a3b1..7815bccf2 100644 --- a/packages/openapi/package.json +++ b/packages/openapi/package.json @@ -1,6 +1,6 @@ { "name": "fumadocs-openapi", - "version": "5.10.4", + "version": "5.10.5", "description": "Generate MDX docs for your OpenAPI spec", "keywords": [ "NextJs", diff --git a/packages/ui/CHANGELOG.md b/packages/ui/CHANGELOG.md index f3ccda611..0b10013c0 100644 --- a/packages/ui/CHANGELOG.md +++ b/packages/ui/CHANGELOG.md @@ -1,5 +1,12 @@ # next-docs-ui +## 14.6.7 + +### Patch Changes + +- Updated dependencies [5474343] + - fumadocs-core@14.6.7 + ## 14.6.6 ### Patch Changes diff --git a/packages/ui/package.json b/packages/ui/package.json index 405e961d1..fdb09214c 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -1,6 +1,6 @@ { "name": "fumadocs-ui", - "version": "14.6.6", + "version": "14.6.7", "description": "The framework for building a documentation website in Next.js", "keywords": [ "NextJs", From e95be5204ae56891f7c2f71896da8613462c6812 Mon Sep 17 00:00:00 2001 From: Fuma Nama Date: Sun, 29 Dec 2024 08:10:29 +0800 Subject: [PATCH 5/8] UI: fix i18n toggle --- .changeset/mighty-points-fold.md | 5 +++++ packages/ui/src/i18n.tsx | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/mighty-points-fold.md diff --git a/.changeset/mighty-points-fold.md b/.changeset/mighty-points-fold.md new file mode 100644 index 000000000..d0d0bc42c --- /dev/null +++ b/.changeset/mighty-points-fold.md @@ -0,0 +1,5 @@ +--- +'fumadocs-ui': patch +--- + +Fix i18n toggle diff --git a/packages/ui/src/i18n.tsx b/packages/ui/src/i18n.tsx index ac8b70f11..e68dd6f0e 100644 --- a/packages/ui/src/i18n.tsx +++ b/packages/ui/src/i18n.tsx @@ -43,14 +43,14 @@ export function I18nProvider({ const router = useRouter(); const pathname = usePathname(); - const onChangeCallback = (locale: string) => { + const onChangeCallback = (value: string) => { const segments = pathname.split('/').filter((v) => v.length > 0); // If locale prefix hidden if (segments[0] !== locale) { - segments.unshift(locale); + segments.unshift(value); } else { - segments[0] = locale; + segments[0] = value; } router.push(`/${segments.join('/')}`); From f3298eaee5293c63af28ed8ea38dd484978d668f Mon Sep 17 00:00:00 2001 From: Fuma Nama Date: Sun, 29 Dec 2024 08:13:45 +0800 Subject: [PATCH 6/8] UI: add css prefix by default --- .changeset/silly-impalas-double.md | 5 ++++ apps/docs/content/docs/ui/theme.mdx | 26 +++++++++++++++---- .../template/+shared/app/(home)/layout.tsx | 6 +---- .../template/+tailwindcss/tailwind.config.js | 1 + packages/ui/src/tailwind-plugin.ts | 2 +- 5 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 .changeset/silly-impalas-double.md diff --git a/.changeset/silly-impalas-double.md b/.changeset/silly-impalas-double.md new file mode 100644 index 000000000..9813689d9 --- /dev/null +++ b/.changeset/silly-impalas-double.md @@ -0,0 +1,5 @@ +--- +'fumadocs-ui': patch +--- + +Add css prefix by default diff --git a/apps/docs/content/docs/ui/theme.mdx b/apps/docs/content/docs/ui/theme.mdx index 27bf17d54..66135e0fe 100644 --- a/apps/docs/content/docs/ui/theme.mdx +++ b/apps/docs/content/docs/ui/theme.mdx @@ -44,11 +44,7 @@ To enable RTL, set the `dir` prop to `rtl` in body and root provider (required f import { RootProvider } from 'fumadocs-ui/provider'; import type { ReactNode } from 'react'; -export default function RootLayout({ - children, -}: { - children: ReactNode; -}): ReactNode { +export default function RootLayout({ children }: { children: ReactNode }) { return ( @@ -63,6 +59,26 @@ export default function RootLayout({ Fumadocs UI provides some CSS variables for customising the layout. +### Prefix + +By default, it has a `fd-` prefix to avoid conflicts with Shadcn UI or your own CSS variables. + +You can set or remove the prefix in `createPreset`: + +```js +import { createPreset } from 'fumadocs-ui/tailwind-plugin'; + +/** @type {import('tailwindcss').Config} */ +export default { + presets: [ + createPreset({ + // no prefix + cssPrefix: '', + }), + ], +}; +``` + ### Navbar Height When the default navbar is replaced, the layout may overlap with your new navbar. diff --git a/packages/create-app/template/+shared/app/(home)/layout.tsx b/packages/create-app/template/+shared/app/(home)/layout.tsx index 608a58b1d..1dd4684d0 100644 --- a/packages/create-app/template/+shared/app/(home)/layout.tsx +++ b/packages/create-app/template/+shared/app/(home)/layout.tsx @@ -2,10 +2,6 @@ import type { ReactNode } from 'react'; import { HomeLayout } from 'fumadocs-ui/layouts/home'; import { baseOptions } from '@/app/layout.config'; -export default function Layout({ - children, -}: { - children: ReactNode; -}): React.ReactElement { +export default function Layout({ children }: { children: ReactNode }) { return {children}; } diff --git a/packages/create-app/template/+tailwindcss/tailwind.config.js b/packages/create-app/template/+tailwindcss/tailwind.config.js index c9b20f90c..c343ccec8 100644 --- a/packages/create-app/template/+tailwindcss/tailwind.config.js +++ b/packages/create-app/template/+tailwindcss/tailwind.config.js @@ -1,3 +1,4 @@ +// @ts-check import { createPreset } from 'fumadocs-ui/tailwind-plugin'; /** @type {import('tailwindcss').Config} */ diff --git a/packages/ui/src/tailwind-plugin.ts b/packages/ui/src/tailwind-plugin.ts index 769d1be15..a5d1509a2 100644 --- a/packages/ui/src/tailwind-plugin.ts +++ b/packages/ui/src/tailwind-plugin.ts @@ -120,7 +120,7 @@ function createTailwindColors( } export const docsUi = plugin.withOptions( - ({ cssPrefix = '', preset = 'default', layoutWidth = '100vw' } = {}) => { + ({ cssPrefix = 'fd', preset = 'default', layoutWidth = '100vw' } = {}) => { return ({ addBase, addComponents, addUtilities }) => { const { light, dark, css } = typeof preset === 'string' ? presets[preset] : preset; From 4255871f0c3e1354b36562eb4e14ae8d663cdaba Mon Sep 17 00:00:00 2001 From: Fuma Nama Date: Sun, 29 Dec 2024 08:27:08 +0800 Subject: [PATCH 7/8] fix tw config --- packages/ui/src/tailwind-plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/src/tailwind-plugin.ts b/packages/ui/src/tailwind-plugin.ts index a5d1509a2..ef5ff9421 100644 --- a/packages/ui/src/tailwind-plugin.ts +++ b/packages/ui/src/tailwind-plugin.ts @@ -240,7 +240,7 @@ export const docsUi = plugin.withOptions( }; }, ({ - cssPrefix = '', + cssPrefix = 'fd', modifyContainer = true, addGlobalColors = false, } = {}) => ({ From 3e6e6bd692f241304caa86bf8ea4b7eb480fe2ca Mon Sep 17 00:00:00 2001 From: Fuma Nama <76240755+fuma-nama@users.noreply.github.com> Date: Sun, 29 Dec 2024 08:31:21 +0800 Subject: [PATCH 8/8] Version Packages (#1202) --- .changeset/mighty-points-fold.md | 5 ----- .changeset/silly-impalas-double.md | 5 ----- packages/core/CHANGELOG.md | 2 ++ packages/core/package.json | 2 +- packages/create-app/CHANGELOG.md | 2 ++ packages/create-app/package.json | 2 +- packages/openapi/CHANGELOG.md | 9 +++++++++ packages/openapi/package.json | 2 +- packages/ui/CHANGELOG.md | 8 ++++++++ packages/ui/package.json | 2 +- 10 files changed, 25 insertions(+), 14 deletions(-) delete mode 100644 .changeset/mighty-points-fold.md delete mode 100644 .changeset/silly-impalas-double.md diff --git a/.changeset/mighty-points-fold.md b/.changeset/mighty-points-fold.md deleted file mode 100644 index d0d0bc42c..000000000 --- a/.changeset/mighty-points-fold.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'fumadocs-ui': patch ---- - -Fix i18n toggle diff --git a/.changeset/silly-impalas-double.md b/.changeset/silly-impalas-double.md deleted file mode 100644 index 9813689d9..000000000 --- a/.changeset/silly-impalas-double.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'fumadocs-ui': patch ---- - -Add css prefix by default diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index ac8f0da72..b256f8129 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -1,5 +1,7 @@ # next-docs-zeta +## 14.6.8 + ## 14.6.7 ### Patch Changes diff --git a/packages/core/package.json b/packages/core/package.json index 87330047a..77b2e6eb0 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "fumadocs-core", - "version": "14.6.7", + "version": "14.6.8", "description": "The library for building a documentation website in Next.js", "keywords": [ "NextJs", diff --git a/packages/create-app/CHANGELOG.md b/packages/create-app/CHANGELOG.md index fc05ead48..3723a411e 100644 --- a/packages/create-app/CHANGELOG.md +++ b/packages/create-app/CHANGELOG.md @@ -1,5 +1,7 @@ # create-next-docs-app +## 14.6.8 + ## 14.6.7 ## 14.6.6 diff --git a/packages/create-app/package.json b/packages/create-app/package.json index d3fa16174..40adbe324 100644 --- a/packages/create-app/package.json +++ b/packages/create-app/package.json @@ -1,6 +1,6 @@ { "name": "create-fumadocs-app", - "version": "14.6.7", + "version": "14.6.8", "description": "Create a new documentation site with Fumadocs", "keywords": [ "NextJs", diff --git a/packages/openapi/CHANGELOG.md b/packages/openapi/CHANGELOG.md index 576ba8134..0cc8e5d66 100644 --- a/packages/openapi/CHANGELOG.md +++ b/packages/openapi/CHANGELOG.md @@ -1,5 +1,14 @@ # @fuma-docs/openapi +## 5.10.6 + +### Patch Changes + +- Updated dependencies [e95be52] +- Updated dependencies [f3298ea] + - fumadocs-ui@14.6.8 + - fumadocs-core@14.6.8 + ## 5.10.5 ### Patch Changes diff --git a/packages/openapi/package.json b/packages/openapi/package.json index 7815bccf2..af1a002ad 100644 --- a/packages/openapi/package.json +++ b/packages/openapi/package.json @@ -1,6 +1,6 @@ { "name": "fumadocs-openapi", - "version": "5.10.5", + "version": "5.10.6", "description": "Generate MDX docs for your OpenAPI spec", "keywords": [ "NextJs", diff --git a/packages/ui/CHANGELOG.md b/packages/ui/CHANGELOG.md index 0b10013c0..5cbe49a38 100644 --- a/packages/ui/CHANGELOG.md +++ b/packages/ui/CHANGELOG.md @@ -1,5 +1,13 @@ # next-docs-ui +## 14.6.8 + +### Patch Changes + +- e95be52: Fix i18n toggle +- f3298ea: Add css prefix by default + - fumadocs-core@14.6.8 + ## 14.6.7 ### Patch Changes diff --git a/packages/ui/package.json b/packages/ui/package.json index fdb09214c..b0d272ecd 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -1,6 +1,6 @@ { "name": "fumadocs-ui", - "version": "14.6.7", + "version": "14.6.8", "description": "The framework for building a documentation website in Next.js", "keywords": [ "NextJs",