Update fumadocs template to v16.5.1 with i18n and LLM support#47
Update fumadocs template to v16.5.1 with i18n and LLM support#47
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Update fumadocs-core, fumadocs-mdx, fumadocs-ui to 16.5.1/14.2.6 - Update Next.js to 16.1.6, React to 19.2.4 - Migrate source.config.ts to new defineDocs API with schemas - Migrate lib/source.ts to use docs.toFumadocsSource() and lucideIconsPlugin - Move layout.config.tsx to lib/layout.shared.tsx (function-based) - Update mdx-components.tsx to getMDXComponents pattern - Update tsconfig.json with fumadocs-mdx:collections path mapping - Add postcss.config.mjs and app/global.css - Update search API to use createFromSource with localeMap - Update DocsPage to use DocsTitle/DocsDescription/DocsBody components - Add LLM routes (llms.txt, llms-full.txt, llms.mdx) - Add OG image generation route - Add AI page actions component (copy markdown, open in AI tools) - Add next.config.mjs rewrites for MDX URL support - Add lib/cn.ts utility Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…cludeProcessedMarkdown comment Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
🚀 Preview DeploymentThis pull request will be automatically deployed to Vercel. Preview Links
Build StatusCheck the CI workflow for build status and any errors. Automated preview information for PR #47 |
There was a problem hiding this comment.
Pull request overview
Updates the ObjectDocs site package to match the latest Fumadocs v16.5.1 scaffold, while keeping the existing i18n routing and adding LLM/OG features for docs consumption and sharing.
Changes:
- Bumps Fumadocs/Next/React-related dependencies and migrates to the newer Fumadocs collections/source/search APIs.
- Adds LLM-focused endpoints (
/llms.txt,/llms-full.txt, and rewritten/docs/*.mdx) plus OG image generation routes. - Refactors layout/config plumbing (shared base layout options, Tailwind v4 PostCSS setup, global CSS imports) and adjusts middleware matchers for new routes.
Reviewed changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Locks updated dependency graph for Fumadocs/Next/React upgrades and new packages. |
| package.json | Bumps root React/lucide/tailwind-merge versions to match site package. |
| packages/site/package.json | Updates Fumadocs/Next deps, moves type packages to devDependencies, adds types:check and postinstall. |
| packages/site/tsconfig.json | Adds baseUrl, updates target, and introduces fumadocs-mdx:collections/* path mapping. |
| packages/site/source.config.ts | Migrates defineDocs config to use schemas + processed markdown for LLM extraction. |
| packages/site/postcss.config.mjs | Adds Tailwind v4 PostCSS plugin config. |
| packages/site/next.config.mjs | Adds rewrite for /docs/:path*.mdx to LLM markdown route. |
| packages/site/middleware.ts | Updates matcher exclusions for LLM/OG routes while preserving i18n middleware behavior. |
| packages/site/mdx-components.tsx | Switches to getMDXComponents() pattern with default Fumadocs MDX components. |
| packages/site/lib/source.ts | Switches to collections loader + adds lucide icons plugin, plus LLM/OG helper functions. |
| packages/site/lib/layout.shared.tsx | Refactors base layout options into a shared function for reuse. |
| packages/site/lib/cn.ts | Adds cn helper exported from tailwind-merge. |
| packages/site/components/ai/page-actions.tsx | Adds client-side LLM page actions (copy markdown + open in external chat tools). |
| packages/site/app/layout.tsx | Switches root layout styling to Tailwind class + imports new global CSS. |
| packages/site/app/global.css | Introduces Tailwind + Fumadocs UI CSS imports via Tailwind v4 @import pattern. |
| packages/site/app/api/search/route.ts | Migrates search endpoint to createFromSource with locale mapping. |
| packages/site/app/[lang]/layout.tsx | Simplifies i18n provider layout to wrap children without redefining html/body. |
| packages/site/app/[lang]/docs/layout.tsx | Uses shared base layout options function and spreads into DocsLayout. |
| packages/site/app/[lang]/docs/[[...slug]]/page.tsx | Migrates DocsPage rendering to new Fumadocs page components + relative link handling + OG metadata. |
| packages/site/app/llms.txt/route.ts | Adds /llms.txt listing for docs pages. |
| packages/site/app/llms-full.txt/route.ts | Adds /llms-full.txt full concatenated LLM text export. |
| packages/site/app/llms.mdx/docs/[[...slug]]/route.ts | Adds per-page markdown export route backing /docs/*.mdx rewrite. |
| packages/site/app/og/docs/[...slug]/route.tsx | Adds OG image route using fumadocs-ui/og. |
| packages/site/app/layout.config.tsx | Removes old static baseOptions export in favor of shared layout helper. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
| export async function GET(_req: Request, { params }: RouteContext<'/og/docs/[...slug]'>) { | ||
| const { slug } = await params; |
There was a problem hiding this comment.
RouteContext is referenced in the GET handler signature but is not defined/imported anywhere in the repo, which will cause a TypeScript compile error. Replace it with an explicit context type (e.g., { params: { slug: string[] } } or the appropriate Next-generated type) or import the correct type if it exists.
| const { slug } = await params; | ||
| const page = source.getPage(slug.slice(0, -1)); | ||
| if (!page) notFound(); |
There was a problem hiding this comment.
This OG route isn’t locale-aware: source.getPage(...) is called without a lang, and getPageImage() doesn’t include page.locale in the generated URL segments. For i18n pages this can return the default-language page and also causes URL collisions between locales; include locale in the OG URL/params and pass the correct language into source.getPage.
| export function generateStaticParams() { | ||
| return source.getPages().map((page) => ({ | ||
| lang: page.locale, | ||
| slug: getPageImage(page).segments, | ||
| })); |
There was a problem hiding this comment.
generateStaticParams() returns an extra lang field even though this route only has a [...slug] param. Next’s static params are expected to match the route’s dynamic segments; either add a [lang] segment to the route path or fold the locale into slug so the params shape matches the route.
| export async function GET(_req: Request, { params }: RouteContext<'/llms.mdx/docs/[[...slug]]'>) { | ||
| const { slug } = await params; | ||
| const page = source.getPage(slug); |
There was a problem hiding this comment.
RouteContext is referenced in the GET handler signature but is not defined/imported anywhere in the repo, which will cause a TypeScript compile error. Replace it with an explicit context type for params (or import the correct Next-generated type if available).
| export function getPageImage(page: InferPageType<typeof source>) { | ||
| const segments = [...page.slugs, 'image.png']; | ||
|
|
||
| return { | ||
| segments, | ||
| url: `/og/docs/${segments.join('/')}`, | ||
| }; |
There was a problem hiding this comment.
getPageImage() builds OG image URLs without including page.locale. In an i18n setup this can produce identical OG URLs for different locales and makes it impossible for the OG route to reliably render the correct-language page. Include the locale in segments/url (and align the OG route params parsing accordingly).
Aligns the site template with the latest
pnpm create fumadocs-appscaffold while preserving i18n routing.Dependency updates
16.5.1, fumadocs-mdx14.2.6, Next.js16.1.6, React19.2.4@fumadocs/uiandautoprefixer; moved type packages todevDependenciesAPI migrations
defineDocs()now usesfrontmatterSchema/metaSchemawithincludeProcessedMarkdownfor LLM text extractiontoFumadocsSource(docs, meta)→docs.toFumadocsSource(), addedlucideIconsPlugincreateSearchAPI('advanced', {...})→createFromSource(source, { localeMap })— mapscnto'english'tokenizer since Orama doesn't support Chinese nativelyuseMDXComponents→getMDXComponentsDocsTitle+DocsDescription+DocsBody+createRelativeLinkfumadocs-mdx:collections/*path mappingNew features
/llms.txt,/llms-full.txt,/docs/*.mdx(via Next.js rewrites)/og/docs/[...slug]withfumadocs-ui/ogglobal.csswith Tailwind v4@importpattern +postcss.config.mjslayout.config.tsx(object export) →lib/layout.shared.tsx(function)i18n
Middleware updated to exclude
/llms.*and/og/from i18n redirects.[lang]routing, language switcher, and translations all preserved.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.