Skip to content
Draft
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ yarn-error.log*

.idea
.vscode
.turbo
.turbo

.source
45 changes: 45 additions & 0 deletions apps/dev-docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# dev-docs

This is a Next.js application generated with
[Create Fumadocs](https://github.com/fuma-nama/fumadocs).

Run development server:

```bash
npm run dev
# or
pnpm dev
# or
yarn dev
```

Open http://localhost:3000 with your browser to see the result.

## Explore

In the project, you can see:

- `lib/source.ts`: Code for content source adapter, [`loader()`](https://fumadocs.dev/docs/headless/source-api) provides the interface to access your content.
- `lib/layout.shared.tsx`: Shared options for layouts, optional but preferred to keep.

| Route | Description |
| ------------------------- | ------------------------------------------------------ |
| `app/(home)` | The route group for your landing page and other pages. |
| `app/docs` | The documentation layout and pages. |
| `app/api/search/route.ts` | The Route Handler for search. |

### Fumadocs MDX

A `source.config.ts` config file has been included, you can customise different options like frontmatter schema.

Read the [Introduction](https://fumadocs.dev/docs/mdx) for further details.

## Learn More

To learn more about Next.js and Fumadocs, take a look at the following
resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js
features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
- [Fumadocs](https://fumadocs.vercel.app) - learn about Fumadocs
6 changes: 6 additions & 0 deletions apps/dev-docs/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference path="./.next/types/routes.d.ts" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
10 changes: 10 additions & 0 deletions apps/dev-docs/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { createMDX } from 'fumadocs-mdx/next';

const withMDX = createMDX();

/** @type {import('next').NextConfig} */
const config = {
reactStrictMode: true,
};

export default withMDX(config);
36 changes: 36 additions & 0 deletions apps/dev-docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "dev-docs",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "next build",
"dev": "next dev --turbo --port 3001",
"start": "next start",
"postinstall": "fumadocs-mdx"
},
"dependencies": {
"@repo/api": "workspace:*",
"fumadocs-core": "15.7.10",
"fumadocs-mdx": "11.9.0",
"fumadocs-openapi": "^9.3.7",
"fumadocs-ui": "15.7.10",
"next": "15.5.2",
"react": "^19.1.1",
"react-dom": "^19.1.1",
"shiki": "^3.12.2",
"trpc-to-openapi": "^3.0.1",
"zod": "^4.1.5"
},
"devDependencies": {
"@types/node": "24.3.1",
"@types/react": "^19.1.12",
"@types/react-dom": "^19.1.9",
"typescript": "^5.9.2",
"@types/mdx": "^2.0.13",
"@tailwindcss/postcss": "^4.1.13",
"tailwindcss": "^4.1.13",
"postcss": "^8.5.6",
"eslint": "^8",
"eslint-config-next": "15.5.2"
}
}
5 changes: 5 additions & 0 deletions apps/dev-docs/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
plugins: {
'@tailwindcss/postcss': {},
},
};
23 changes: 23 additions & 0 deletions apps/dev-docs/source.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {
defineConfig,
defineDocs,
frontmatterSchema,
metaSchema,
} from 'fumadocs-mdx/config';

// You can customise Zod schemas for frontmatter and `meta.json` here
// see https://fumadocs.dev/docs/mdx/collections#define-docs
export const docs = defineDocs({
docs: {
schema: frontmatterSchema,
},
meta: {
schema: metaSchema,
},
});

export default defineConfig({
mdxOptions: {
// MDX options
},
});
6 changes: 6 additions & 0 deletions apps/dev-docs/src/app/(home)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { HomeLayout } from 'fumadocs-ui/layouts/home';
import { baseOptions } from '@/lib/layout.shared';

export default function Layout({ children }: LayoutProps<'/'>) {
return <HomeLayout {...baseOptions()}>{children}</HomeLayout>;
}
19 changes: 19 additions & 0 deletions apps/dev-docs/src/app/(home)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Link from 'next/link';

export default function HomePage() {
return (
<main className="flex flex-1 flex-col justify-center text-center">
<h1 className="mb-4 text-2xl font-bold">Hello World</h1>
<p className="text-fd-muted-foreground">
You can open{' '}
<Link
href="/docs"
className="text-fd-foreground font-semibold underline"
>
/docs
</Link>{' '}
and see the documentation.
</p>
</main>
);
}
7 changes: 7 additions & 0 deletions apps/dev-docs/src/app/api/search/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { source } from '@/lib/source';
import { createFromSource } from 'fumadocs-core/search/server';

export const { GET } = createFromSource(source, {
// https://docs.orama.com/docs/orama-js/supported-languages
language: 'english',
});
51 changes: 51 additions & 0 deletions apps/dev-docs/src/app/docs/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { source } from '@/lib/source';
import {
DocsBody,
DocsDescription,
DocsPage,
DocsTitle,
} from 'fumadocs-ui/page';
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';
import { createRelativeLink } from 'fumadocs-ui/mdx';
import { getMDXComponents } from '@/mdx-components';

export default async function Page(props: PageProps<'/docs/[[...slug]]'>) {
const params = await props.params;
const page = source.getPage(params.slug);
if (!page) notFound();

const MDXContent = page.data.body;

return (
<DocsPage toc={page.data.toc} full={page.data.full}>
<DocsTitle>{page.data.title}</DocsTitle>
<DocsDescription>{page.data.description}</DocsDescription>
<DocsBody>
<MDXContent
components={getMDXComponents({
// this allows you to link to other pages with relative file paths
a: createRelativeLink(source, page),
})}
/>
</DocsBody>
</DocsPage>
);
}

export async function generateStaticParams() {
return source.generateParams();
}

export async function generateMetadata(
props: PageProps<'/docs/[[...slug]]'>,
): Promise<Metadata> {
const params = await props.params;
const page = source.getPage(params.slug);
if (!page) notFound();

return {
title: page.data.title,
description: page.data.description,
};
}
11 changes: 11 additions & 0 deletions apps/dev-docs/src/app/docs/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
import { baseOptions } from '@/lib/layout.shared';
import { source } from '@/lib/source';

export default function Layout({ children }: LayoutProps<'/docs'>) {
return (
<DocsLayout tree={source.pageTree} {...baseOptions()}>
{children}
</DocsLayout>
);
}
4 changes: 4 additions & 0 deletions apps/dev-docs/src/app/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@import 'tailwindcss';
@import 'fumadocs-ui/css/neutral.css';
@import 'fumadocs-ui/css/preset.css';
@import 'fumadocs-openapi/css/preset.css';
17 changes: 17 additions & 0 deletions apps/dev-docs/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import '@/app/global.css';
import { RootProvider } from 'fumadocs-ui/provider';
import { Inter } from 'next/font/google';

const inter = Inter({
subsets: ['latin'],
});

export default function Layout({ children }: LayoutProps<'/'>) {
return (
<html lang="en" className={inter.className} suppressHydrationWarning>
<body className="flex flex-col min-h-screen">
<RootProvider>{children}</RootProvider>
</body>
</html>
);
}
30 changes: 30 additions & 0 deletions apps/dev-docs/src/lib/layout.shared.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';

/**
* Shared layout configurations
*
* you can customise layouts individually from:
* Home Layout: app/(home)/layout.tsx
* Docs Layout: app/docs/layout.tsx
*/
export function baseOptions(): BaseLayoutProps {
return {
nav: {
title: (
<>
<svg
width="24"
height="24"
xmlns="http://www.w3.org/2000/svg"
aria-label="Logo"
>
<circle cx={12} cy={12} r={12} fill="currentColor" />
</svg>
My App
</>
),
},
// see https://fumadocs.dev/docs/ui/navigation/links
links: [],
};
}
25 changes: 25 additions & 0 deletions apps/dev-docs/src/lib/openapi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { createOpenAPI } from 'fumadocs-openapi/server';
import { openApiDocument } from '@repo/api/openapi';

export const openapi = createOpenAPI({
async input() {
return {
// [id]: downloaded OpenAPI Schema
my_schema: await fetch(
'http://localhost:3000/api/openapi.json',
).then((res) => res.json()),
};
},
});

import { generateFiles } from "fumadocs-openapi";
void generateFiles({
// the OpenAPI schema, you can also give it an external URL.
input: ["http://localhost:3000/api/openapi.json"],
output: "./content/docs/router",
// we recommend to enable it
// make sure your endpoint description doesn't break MDX syntax.
includeDescription: true,
});

console.log(JSON.stringify(openapi.getSchemas(), null, 2));
15 changes: 15 additions & 0 deletions apps/dev-docs/src/lib/source.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { docs } from '@/.source';
import { loader } from 'fumadocs-core/source';
import { transformerOpenAPI } from 'fumadocs-openapi/server';

// See https://fumadocs.vercel.app/docs/headless/source-api for more info
export const source = loader({
// it assigns a URL to your pages
baseUrl: '/docs',
source: docs.toFumadocsSource(),
pageTree: {
// adds a badge to each page item in page tree
transformers: [transformerOpenAPI()],
},
});

13 changes: 13 additions & 0 deletions apps/dev-docs/src/mdx-components.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import defaultMdxComponents from 'fumadocs-ui/mdx';
import { APIPage } from 'fumadocs-openapi/ui';
import type { MDXComponents } from 'mdx/types';
import { openapi } from '@/lib/openapi';

// use this function to get MDX components, you will need it for rendering MDX
export function getMDXComponents(components?: MDXComponents): MDXComponents {
return {
...defaultMdxComponents,
APIPage: (props) => <APIPage {...openapi.getAPIPageProps(props)} />,
...components,
};
}
45 changes: 45 additions & 0 deletions apps/dev-docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"compilerOptions": {
"baseUrl": ".",
"target": "ESNext",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"paths": {
"@/.source": [
"./.source/index.ts"
],
"@/*": [
"./src/*"
]
},
"plugins": [
{
"name": "next"
}
]
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
Loading
Loading