Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync #1203

Merged
merged 8 commits into from
Dec 29, 2024
Merged

Sync #1203

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions apps/docs/content/docs/ui/internationalization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Translations> = {
search: 'Translated Content',
// other props
// other translations
};

// available languages that will be displayed on UI
Expand All @@ -104,16 +104,18 @@ export default async function RootLayout({
params: Promise<{ lang: string }>;
children: React.ReactNode;
}) {
const lang = (await params).lang;

return (
<html lang={(await params).lang}>
<html lang={lang}>
<body>
<I18nProvider
locale={(await params).lang}
locale={lang}
locales={locales}
translations={
{
cn,
}[(await params).lang]
}[lang]
}
>
<RootProvider>{children}</RootProvider>
Expand All @@ -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';
Expand All @@ -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';
Expand Down
26 changes: 21 additions & 5 deletions apps/docs/content/docs/ui/theme.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<html lang="en" suppressHydrationWarning>
<body dir="rtl">
Expand All @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# next-docs-zeta

## 14.6.8

## 14.6.7

### Patch Changes

- 5474343: Export dynamic-link

## 14.6.6

## 14.6.5
Expand Down
6 changes: 5 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fumadocs-core",
"version": "14.6.6",
"version": "14.6.8",
"description": "The library for building a documentation website in Next.js",
"keywords": [
"NextJs",
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions packages/create-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# create-next-docs-app

## 14.6.8

## 14.6.7

## 14.6.6

## 14.6.5
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-fumadocs-app",
"version": "14.6.6",
"version": "14.6.8",
"description": "Create a new documentation site with Fumadocs",
"keywords": [
"NextJs",
Expand Down
6 changes: 1 addition & 5 deletions packages/create-app/template/+shared/app/(home)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <HomeLayout {...baseOptions}>{children}</HomeLayout>;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-check
import { createPreset } from 'fumadocs-ui/tailwind-plugin';

/** @type {import('tailwindcss').Config} */
Expand Down
17 changes: 17 additions & 0 deletions packages/openapi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# @fuma-docs/openapi

## 5.10.6

### Patch Changes

- Updated dependencies [e95be52]
- Updated dependencies [f3298ea]
- [email protected]
- [email protected]

## 5.10.5

### Patch Changes

- Updated dependencies [5474343]
- [email protected]
- [email protected]

## 5.10.4

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fumadocs-openapi",
"version": "5.10.4",
"version": "5.10.6",
"description": "Generate MDX docs for your OpenAPI spec",
"keywords": [
"NextJs",
Expand Down
15 changes: 15 additions & 0 deletions packages/ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# next-docs-ui

## 14.6.8

### Patch Changes

- e95be52: Fix i18n toggle
- f3298ea: Add css prefix by default
- [email protected]

## 14.6.7

### Patch Changes

- Updated dependencies [5474343]
- [email protected]

## 14.6.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fumadocs-ui",
"version": "14.6.6",
"version": "14.6.8",
"description": "The framework for building a documentation website in Next.js",
"keywords": [
"NextJs",
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/src/i18n.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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('/')}`);
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/tailwind-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function createTailwindColors(
}

export const docsUi = plugin.withOptions<DocsUIOptions>(
({ 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;
Expand Down Expand Up @@ -240,7 +240,7 @@ export const docsUi = plugin.withOptions<DocsUIOptions>(
};
},
({
cssPrefix = '',
cssPrefix = 'fd',
modifyContainer = true,
addGlobalColors = false,
} = {}) => ({
Expand Down
Loading