Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: fuma-nama/fumadocs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: @fumadocs/cli@0.1.0
Choose a base ref
...
head repository: fuma-nama/fumadocs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: @fumadocs/cli@0.1.1
Choose a head ref

Commits on Apr 2, 2025

  1. Docs: correct content

    fuma-nama committed Apr 2, 2025
    Copy the full SHA
    77d29d0 View commit details
  2. add changesets

    fuma-nama committed Apr 2, 2025
    Copy the full SHA
    0829544 View commit details
  3. CLI: preserve registry output order

    fuma-nama committed Apr 2, 2025
    Copy the full SHA
    73a5c3f View commit details
  4. Merge pull request #1658 from fuma-nama/changeset-release/dev

    Version Packages
    fuma-nama authored Apr 2, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    dfc5ee3 View commit details

Commits on Apr 3, 2025

  1. Copy the full SHA
    0c33357 View commit details
  2. bump deps

    fuma-nama committed Apr 3, 2025
    Copy the full SHA
    f9d700d View commit details
  3. TypeScript: add null | undefined to optional props in a object type

    fuma-nama committed Apr 3, 2025
    Copy the full SHA
    38117c1 View commit details
  4. update test snapshots

    fuma-nama committed Apr 3, 2025
    Copy the full SHA
    84c9af6 View commit details
  5. TypeScript: remove undefined union member from optional prop

    fuma-nama committed Apr 3, 2025
    Copy the full SHA
    af109e5 View commit details
  6. Version Packages (#1665)

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    fuma-nama and github-actions[bot] authored Apr 3, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    95bb1df View commit details
  7. Update route-tag.ts (#1646)

    * Update route-tag.ts
    
    The existing "<value>" placeholder can be improved by adding a comment next to it that tells the likely way to get the tag, based on the slugs of the page.
    
    * Update route-tag.ts
    
    ---------
    
    Co-authored-by: tectonic504 <63996665+tectonic504@users.noreply.github.com>
    Co-authored-by: Fuma Nama <76240755+fuma-nama@users.noreply.github.com>
    3 people authored Apr 3, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    941a24e View commit details
  8. Copy the full SHA
    293178f View commit details
  9. UI: Deprecate I18nProvider in favour of <RootProvider /> i18n prop

    fuma-nama committed Apr 3, 2025
    Copy the full SHA
    5e4e9ec View commit details
  10. Merge pull request #1668 from fuma-nama/changeset-release/dev

    Version Packages
    fuma-nama authored Apr 3, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    aa6f20a View commit details
  11. Docs: update usage

    fuma-nama committed Apr 3, 2025
    Copy the full SHA
    1d8aca2 View commit details

Commits on Apr 4, 2025

  1. Core & UI: fix type unions on dynamic codeblock

    fuma-nama committed Apr 4, 2025
    Copy the full SHA
    1057957 View commit details
  2. Copy the full SHA
    6c5e47a View commit details
  3. Copy the full SHA
    482f728 View commit details
  4. Copy the full SHA
    9e67297 View commit details
  5. Copy the full SHA
    fac375b View commit details
  6. Core & UI: expose utils

    fuma-nama committed Apr 4, 2025
    Copy the full SHA
    c51287d View commit details
  7. update tests

    fuma-nama committed Apr 4, 2025
    Copy the full SHA
    2936011 View commit details
  8. Docs: remove Category docs, move the section to /markdown

    fuma-nama committed Apr 4, 2025
    Copy the full SHA
    0631f8b View commit details
  9. Version Packages (#1672)

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    fuma-nama and github-actions[bot] authored Apr 4, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e8589f0 View commit details
Showing with 1,878 additions and 1,616 deletions.
  1. +1 −1 apps/docs/app/(home)/page.tsx
  2. +19 −6 apps/docs/app/docs/[...slug]/page.tsx
  3. +0 −6 apps/docs/app/global.css
  4. +43 −0 apps/docs/components/mdx/mermaid.tsx
  5. +10 −1 apps/docs/components/preview/dynamic-codeblock.tsx
  6. +11 −15 apps/docs/content/docs/cli/index.mdx
  7. +29 −19 apps/docs/content/docs/ui/(integrations)/mermaid.mdx
  8. +4 −0 apps/docs/content/docs/ui/components/dynamic-codeblock.mdx
  9. +3 −3 apps/docs/content/docs/ui/customisation.mdx
  10. +12 −8 apps/docs/content/docs/ui/internationalization.mdx
  11. +0 −19 apps/docs/content/docs/ui/layouts/docs.mdx
  12. +0 −19 apps/docs/content/docs/ui/layouts/page.mdx
  13. +29 −33 apps/docs/content/docs/ui/markdown.mdx
  14. +31 −33 apps/docs/content/docs/ui/navigation/links.mdx
  15. +19 −0 apps/docs/content/docs/ui/navigation/sidebar.mdx
  16. +10 −9 apps/docs/package.json
  17. +5 −5 apps/react-router/package.json
  18. +6 −6 apps/tanstack-start/package.json
  19. +2 −2 examples/content-collections/package.json
  20. +18 −19 examples/i18n/app/[lang]/layout.tsx
  21. +2 −2 examples/i18n/package.json
  22. +1 −0 examples/next-mdx/app/api/search/route-tag.ts
  23. +2 −2 examples/next-mdx/package.json
  24. +5 −5 examples/openapi/package.json
  25. +2 −2 examples/remote-mdx/package.json
  26. +6 −0 packages/cli/CHANGELOG.md
  27. +3 −3 packages/cli/package.json
  28. +48 −51 packages/cli/src/build/build-registry.ts
  29. +30 −4 packages/cli/src/commands/customise.ts
  30. +4 −4 packages/cli/test/out/extended/popover.json
  31. +1 −1 packages/content-collections/package.json
  32. +14 −0 packages/core/CHANGELOG.md
  33. +7 −7 packages/core/package.json
  34. +2 −0 packages/core/src/highlight/index.ts
  35. +6 −2 packages/core/src/highlight/shiki.ts
  36. +1 −1 packages/core/src/server/index.ts
  37. +36 −1 packages/core/src/{server/page-tree-utils.ts → utils/page-tree.tsx}
  38. +1 −1 packages/core/test/index.test.ts
  39. +8 −8 packages/create-app-versions/package.json
  40. +6 −0 packages/create-app/CHANGELOG.md
  41. +2 −2 packages/create-app/package.json
  42. +2 −2 packages/doc-gen/package.json
  43. +2 −2 packages/mdx-remote/package.json
  44. +8 −0 packages/mdx/CHANGELOG.md
  45. +2 −2 packages/mdx/package.json
  46. +1 −1 packages/mdx/src/config/define.ts
  47. +26 −0 packages/openapi/CHANGELOG.md
  48. +8 −8 packages/openapi/package.json
  49. +2 −2 packages/twoslash/package.json
  50. +6 −0 packages/typescript/CHANGELOG.md
  51. +5 −5 packages/typescript/package.json
  52. +21 −3 packages/typescript/src/lib/base.ts
  53. +2 −4 packages/typescript/src/lib/remark-auto-type-table.tsx
  54. 0 packages/typescript/src/{utils → lib}/type-table.ts
  55. +2 −3 packages/typescript/src/ui/auto-type-table.tsx
  56. +24 −0 packages/ui/CHANGELOG.md
  57. +10 −6 packages/ui/package.json
  58. +31 −25 packages/ui/src/_registry/index.ts
  59. +6 −3 packages/ui/src/components/dynamic-codeblock.tsx
  60. +7 −1 packages/ui/src/components/layout/sidebar.tsx
  61. +3 −81 packages/ui/src/contexts/i18n.tsx
  62. +64 −6 packages/ui/src/i18n.tsx
  63. +1 −3 packages/ui/src/layouts/docs.tsx
  64. +8 −109 packages/ui/src/layouts/docs/shared.tsx
  65. +20 −15 packages/ui/src/layouts/home.tsx
  66. +0 −1 packages/ui/src/layouts/links.tsx
  67. +0 −2 packages/ui/src/layouts/notebook.tsx
  68. +90 −1 packages/ui/src/provider/base.tsx
  69. +67 −0 packages/ui/src/utils/get-sidebar-tabs.tsx
  70. +1,021 −1,031 pnpm-lock.yaml
2 changes: 1 addition & 1 deletion apps/docs/app/(home)/page.tsx
Original file line number Diff line number Diff line change
@@ -689,7 +689,7 @@ function Features() {
description="Fumadocs CLI creates interactive components for your docs, offering a rich experience to your users."
>
<CodeBlock
code="npx fumadocs add accordion"
code="npx @fumadocs/cli add"
lang="bash"
wrapper={{
title: 'Terminal',
25 changes: 19 additions & 6 deletions apps/docs/app/docs/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ import {
DocsBody,
DocsTitle,
DocsDescription,
DocsCategory,
} from 'fumadocs-ui/page';
import { notFound } from 'next/navigation';
import {
@@ -24,7 +23,7 @@ import { openapi, source } from '@/lib/source';
import { Wrapper } from '@/components/preview/wrapper';
import { metadataImage } from '@/lib/metadata-image';
import { File, Folder, Files } from 'fumadocs-ui/components/files';
import { Mermaid } from '@theguild/remark-mermaid/mermaid';
import { Mermaid } from '@/components/mdx/mermaid';
import { Rate } from '@/components/rate';
import { repo, owner, onRateAction } from '@/lib/github';
import type { MDXComponents } from 'mdx/types';
@@ -38,6 +37,8 @@ import Link from 'fumadocs-core/link';
import { UiOverview } from '@/components/ui-overview';
import { AutoTypeTable } from 'fumadocs-typescript/ui';
import { createGenerator } from 'fumadocs-typescript';
import { getPageTreePeers } from 'fumadocs-core/server';
import { Card, Cards } from 'fumadocs-ui/components/card';

function PreviewRenderer({ preview }: { preview: string }): ReactNode {
if (preview && preview in Preview) {
@@ -137,22 +138,34 @@ export default async function Page(props: {
Files,
blockquote: Callout as unknown as FC<ComponentProps<'blockquote'>>,
APIPage: openapi.APIPage,
DocsCategory: ({ slugs = params.slug }: { slugs?: string[] }) => (
<DocsCategory page={source.getPage(slugs)!} from={source} />
),
DocsCategory: ({ url }) => {
return <DocsCategory url={url ?? page.url} />;
},
UiOverview,

...(await import('@/content/docs/ui/components/tabs.client')),
...(await import('@/content/docs/ui/theme.client')),
}}
/>
{page.data.index ? <DocsCategory page={page} from={source} /> : null}
{page.data.index ? <DocsCategory url={page.url} /> : null}
</DocsBody>
<Rate onRateAction={onRateAction} />
</DocsPage>
);
}

function DocsCategory({ url }: { url: string }) {
return (
<Cards>
{getPageTreePeers(source.pageTree, url).map((peer) => (
<Card key={peer.url} title={peer.name} href={peer.url}>
{peer.description}
</Card>
))}
</Cards>
);
}

export async function generateMetadata(props: {
params: Promise<{ slug: string[] }>;
}): Promise<Metadata> {
6 changes: 0 additions & 6 deletions apps/docs/app/global.css
Original file line number Diff line number Diff line change
@@ -10,12 +10,6 @@
@source '../node_modules/fumadocs-openapi/dist/**/*.js';
@plugin 'tailwindcss-animate';

@layer base {
button {
cursor: pointer;
}
}

@theme {
@keyframes stroke {
from {
43 changes: 43 additions & 0 deletions apps/docs/components/mdx/mermaid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use client';

import { useEffect, useId, useRef, useState } from 'react';
import type { MermaidConfig } from 'mermaid';
import { useTheme } from 'next-themes';

export function Mermaid({ chart }: { chart: string }) {
const id = useId();
const [svg, setSvg] = useState('');
const containerRef = useRef<HTMLDivElement>(null!);
const { resolvedTheme } = useTheme();

useEffect(() => {
void renderChart();

async function renderChart() {
const mermaidConfig: MermaidConfig = {
startOnLoad: false,
securityLevel: 'loose',
fontFamily: 'inherit',
themeCSS: 'margin: 1.5rem auto 0;',
theme: resolvedTheme === 'dark' ? 'dark' : 'default',
};

const { default: mermaid } = await import('mermaid');

try {
mermaid.initialize(mermaidConfig);
const { svg } = await mermaid.render(
// strip invalid characters for `id` attribute
id.replaceAll(':', ''),
chart.replaceAll('\\n', '\n'),
containerRef.current,
);
setSvg(svg);
} catch (error) {
console.error('Error while rendering mermaid', error);
}
}
}, [chart, id, resolvedTheme]);

return <div ref={containerRef} dangerouslySetInnerHTML={{ __html: svg }} />;
}
11 changes: 10 additions & 1 deletion apps/docs/components/preview/dynamic-codeblock.tsx
Original file line number Diff line number Diff line change
@@ -27,7 +27,16 @@ export default function Example() {
className="bg-transparent px-4 py-2 text-sm focus-visible:outline-none"
/>
</div>
<DynamicCodeBlock lang={lang} code={code} options={{}} />
<DynamicCodeBlock
lang={lang}
code={code}
options={{
themes: {
light: 'catppuccin-latte',
dark: 'catppuccin-mocha',
},
}}
/>
</div>
);
}
26 changes: 11 additions & 15 deletions apps/docs/content/docs/cli/index.mdx
Original file line number Diff line number Diff line change
@@ -5,14 +5,10 @@ description: The CLI tool that automates setups and installing components.

## Installation

```package-install
npm install @fumadocs/cli --save-dev
```

Initialize a config for CLI:

```package-install
npx fumadocs
npx @fumadocs/cli
```

You can change the output paths of components in the config.
@@ -22,13 +18,13 @@ You can change the output paths of components in the config.
Select and install components.

```package-install
npx fumadocs add
npx @fumadocs/cli add
```

You can pass component names directly.

```package-install
npx fumadocs add banner files
npx @fumadocs/cli add banner files
```

#### How the magic works?
@@ -46,27 +42,27 @@ Make sure to use the latest version of CLI
A simple way to customise Fumadocs layouts.

```package-install
npx fumadocs customise
npx @fumadocs/cli customise
```

### Tree

Generate files tree for Fumadocs UI `Files` component, using the `tree` command from your terminal.

```bash
pnpm fumadocs tree ./my-dir ./output.tsx
```package-install
npx @fumadocs/cli tree ./my-dir ./output.tsx
```

You can output MDX file too:

```bash
pnpm fumadocs tree ./my-dir ./output.mdx
```package-install
npx @fumadocs/cli tree ./my-dir ./output.mdx
```

See help for further details:

```bash
pnpm fumadocs tree -h
```package-install
npx @fumadocs/cli tree -h
```

#### Example Output
@@ -96,7 +92,7 @@ export default (
Some features of Fumadocs require copying code to get started, it is similar to `codemod` but for configuring features automatically.

```package-install
npx fumadocs init
npx @fumadocs/cli init
```

Please note that some features may change your existing code, make sure to commit your changes to Git before running it.
48 changes: 29 additions & 19 deletions apps/docs/content/docs/ui/(integrations)/mermaid.mdx
Original file line number Diff line number Diff line change
@@ -3,35 +3,45 @@ title: Mermaid
description: Rendering diagrams in your docs
---

Fumadocs doesn't have a built-in Mermaid wrapper provided, instead you can try different approaches easily.
Fumadocs doesn't have a built-in Mermaid wrapper provided, we recommend using `mermaid` directly.

## Setup

`@theguild/remark-mermaid` converts codeblocks to JSX elements using MDX and render them in a React component. It renders the graph on client side.
Install the required dependencies, `next-themes` is used with Fumadocs to manage the light/dark mode.

```package-install
@theguild/remark-mermaid
mermaid next-themes
```

Add their remark plugin, for example (in Fumadocs MDX):
Create the Mermaid component:

```ts title="source.config.ts"
import { defineDocs, defineConfig } from 'fumadocs-mdx/config';
import { remarkMermaid } from '@theguild/remark-mermaid';
<include cwd meta='title="components/mdx/mermaid.tsx"'>
./components/mdx/mermaid.tsx
</include>

export const { docs, meta } = defineDocs({
dir: 'content/docs',
});
> This is originally inspired by [remark-mermaid](https://github.com/the-guild-org/docs/blob/main/packages/remark-mermaid/src/mermaid.tsx).
export default defineConfig({
mdxOptions: {
remarkPlugins: [remarkMermaid],
},
});
Add the component as a MDX component:

```tsx title="/docs/[[...slug]]/page.tsx"
import defaultMdxComponents from 'fumadocs-ui/mdx';
import { Mermaid } from '@/components/mdx/mermaid';

<MdxContent
components={{
...defaultMdxComponents,
Mermaid,
}}
/>;
```

````md
```mermaid
## Usage

Use it in MDX files.

```mdx
<Mermaid
chart="
graph TD;
subgraph AA [Consumers]
A[Mobile app];
@@ -49,9 +59,9 @@ B --> Z;
C --> Z;
Z --> E;
Z --> F;
Z --> G;
Z --> G;"
/>
```
````

<Mermaid
chart="
4 changes: 4 additions & 0 deletions apps/docs/content/docs/ui/components/dynamic-codeblock.mdx
Original file line number Diff line number Diff line change
@@ -29,6 +29,10 @@ import { DynamicCodeBlock } from 'fumadocs-ui/components/dynamic-codeblock';
lang="ts"
code='console.log("Hello World")'
options={{
themes: {
light: 'github-light',
dark: 'github-dark',
},
components: {
// add/override components
},
6 changes: 3 additions & 3 deletions apps/docs/content/docs/ui/customisation.mdx
Original file line number Diff line number Diff line change
@@ -56,17 +56,17 @@ Since the design system is built on Tailwind CSS, you can customise it [with CSS
Fumadocs CLI is a tool that installs components to your codebase, similar to Shadcn UI.

```package-install
npx fumadocs
npx @fumadocs/cli
```

Use it to install Fumadocs UI components:

```package-install
npx fumadocs add
npx @fumadocs/cli add
```

Or customise layouts:

```package-install
npx fumadocs customise
npx @fumadocs/cli customise
```
20 changes: 12 additions & 8 deletions apps/docs/content/docs/ui/internationalization.mdx
Original file line number Diff line number Diff line change
@@ -68,12 +68,12 @@ See [Middleware](/docs/headless/internationalization#middleware) for customisabl

Create a `/app/[lang]` folder, and move all files (e.g. `page.tsx`, `layout.tsx`) from `/app` to the folder.

Wrap the root provider inside `I18nProvider`, and provide available languages & translations to it.
Provide UI translations and other config to `<RootProvider />`.
Note that only English translations are provided by default.

```tsx title="app/[lang]/layout.tsx"
import { RootProvider } from 'fumadocs-ui/provider';
import { I18nProvider, type Translations } from 'fumadocs-ui/i18n';
import type { Translations } from 'fumadocs-ui/i18n';

const cn: Partial<Translations> = {
search: 'Translated Content',
@@ -105,13 +105,17 @@ export default async function RootLayout({
return (
<html lang={lang}>
<body>
<I18nProvider
locale={lang}
locales={locales}
translations={{ cn }[lang]}
<RootProvider
i18n={{
locale: lang,
// available languages
locales,
// translations for UI
translations: { cn }[lang],
}}
>
<RootProvider>{children}</RootProvider>
</I18nProvider>
{children}
</RootProvider>
</body>
</html>
);
19 changes: 0 additions & 19 deletions apps/docs/content/docs/ui/layouts/docs.mdx
Original file line number Diff line number Diff line change
@@ -49,25 +49,6 @@ import { DocsLayout } from 'fumadocs-ui/layouts/docs';

See [Navigation Guide](/docs/ui/navigation/sidebar#sidebar-tabs) for usages.

#### Decoration

Change the icon/styles of tabs.

```tsx
import { DocsLayout } from 'fumadocs-ui/layouts/docs';

<DocsLayout
sidebar={{
tabs: {
transform: (option, node) => ({
...option,
icon: 'my icon',
}),
},
}}
/>;
```

## Nav

A mobile-only navbar, we recommend to customise it from `baseOptions`.
Loading