From 77513bfe756738536f9d23af3e7a5b65d4e7cf9c Mon Sep 17 00:00:00 2001 From: Cuvii Date: Thu, 22 Jan 2026 10:19:41 +0800 Subject: [PATCH 01/10] refactor: enhance static parameter generation and improve heading component - Updated `generateStaticParams` to filter out existing root paths and return a structured array with the root path first for optional catch-all routes. - Refactored the `Heading` component to simplify rendering logic and improve accessibility by incorporating an `id` prop for anchor links. --- src/app/[[...slug]]/page.tsx | 12 ++++----- src/modules/mdx-components/heading.tsx | 35 ++++++++++++-------------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/app/[[...slug]]/page.tsx b/src/app/[[...slug]]/page.tsx index f875de4..9f158f1 100644 --- a/src/app/[[...slug]]/page.tsx +++ b/src/app/[[...slug]]/page.tsx @@ -41,14 +41,12 @@ export default async function Page(props: PageProps<"/[[...slug]]">) { export async function generateStaticParams() { const params = source.generateParams(); - // Ensure we include the root path for optional catch-all routes - const hasRootPath = params.some((p) => !p.slug || p.slug.length === 0); + // For optional catch-all routes with static export, we must include the root path + // Filter out any existing root paths to avoid duplicates + const filteredParams = params.filter((p) => p.slug && p.slug.length > 0); - if (!hasRootPath) { - return [{ slug: undefined }, ...params]; - } - - return params; + // Return root path first, then all other paths + return [{ slug: [] }, ...filteredParams]; } export async function generateMetadata( diff --git a/src/modules/mdx-components/heading.tsx b/src/modules/mdx-components/heading.tsx index 45ca8c2..3187f1b 100644 --- a/src/modules/mdx-components/heading.tsx +++ b/src/modules/mdx-components/heading.tsx @@ -6,29 +6,26 @@ import { useRender } from "@base-ui/react/use-render"; interface HeadingProps extends useRender.ComponentProps<"h1"> {} export function Heading(props: HeadingProps) { - const { render, children, ...otherProps } = props; + const { render, children, id, ...otherProps } = props; + + const headingContent = id ? ( + + {children} + + ) : ( + children + ); + + const defaultProps: useRender.ElementProps<"h1"> = { + className: + "text-text-high font-semibold tracking-tight font-mono leading-[140%]", + children: headingContent, + }; const element = useRender({ defaultTagName: "h1", render, - props: mergeProps( - { - className: - "text-text-high font-semibold tracking-tight font-mono leading-[140%]", - children: ( - <> - {props.id ? ( - - {props.children} - - ) : ( - props.children - )} - - ), - }, - otherProps, - ), + props: mergeProps<"h1">(defaultProps, otherProps), }); return element; From f8adc2c7da38c85caf11cdd79e1f416c577927f3 Mon Sep 17 00:00:00 2001 From: Cuvii Date: Thu, 22 Jan 2026 10:31:21 +0800 Subject: [PATCH 02/10] refactor: update development server port and enhance search dialog integration - Changed the development server port in `package.json` to 3001 for better accessibility. - Integrated `SearchDialog` from `fumadocs-ui` and updated `RootProvider` to include a custom search dialog in `layout.tsx`. - Refactored `DefaultSearchDialog` to export as a named function and improved query handling in `search.tsx`. --- package.json | 2 +- src/app/layout.tsx | 4 +++- src/components/search.tsx | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 068de0d..facc04b 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "build": "next build", - "dev": "next dev --turbo", + "dev": "next dev --turbo -p 3001", "start": "next start", "postinstall": "fumadocs-mdx", "preview": "opennextjs-cloudflare build && opennextjs-cloudflare preview", diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 4eb5245..46b682c 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -5,6 +5,8 @@ import { Inter } from "next/font/google"; import { cn } from "@/lib/cn"; import { source } from "@/lib/source"; import { DocsLayout } from "@/components/layout/docs"; +import { SearchDialog } from "fumadocs-ui/components/dialog/search"; +import { DefaultSearchDialog } from "@/components/search"; const inter = Inter({ subsets: ["latin"], @@ -75,7 +77,7 @@ export default function Layout({ children }: LayoutProps<"/">) { /> - + {children} diff --git a/src/components/search.tsx b/src/components/search.tsx index 09f7197..9b712b9 100644 --- a/src/components/search.tsx +++ b/src/components/search.tsx @@ -23,7 +23,7 @@ function initOrama() { }); } -export default function DefaultSearchDialog(props: SharedProps) { +export function DefaultSearchDialog(props: SharedProps) { const { locale } = useI18n(); // (optional) for i18n const { search, setSearch, query } = useDocsSearch({ type: 'static', @@ -40,8 +40,8 @@ export default function DefaultSearchDialog(props: SharedProps) { - + ); -} \ No newline at end of file +} From cd92624b62bad4f18e36cc0d13896fff34450d41 Mon Sep 17 00:00:00 2001 From: Cuvii Date: Thu, 22 Jan 2026 10:34:43 +0800 Subject: [PATCH 03/10] refactor: enforce static rendering for dynamic pages - Added `dynamic = 'force-static'` export to the `page.tsx` file to ensure static rendering for dynamic routes, improving performance and SEO. --- src/app/[[...slug]]/page.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/[[...slug]]/page.tsx b/src/app/[[...slug]]/page.tsx index 9f158f1..532b15b 100644 --- a/src/app/[[...slug]]/page.tsx +++ b/src/app/[[...slug]]/page.tsx @@ -12,6 +12,8 @@ import { source } from "@/lib/source"; import { getMDXComponents } from "@/mdx-components"; import { A } from "@/modules/mdx-components/a"; +export const dynamic = 'force-static'; + export default async function Page(props: PageProps<"/[[...slug]]">) { const params = await props.params; const page = source.getPage(params.slug); From 8dbf15605f24236fc9f6cbc91ce35a45d44f4b0e Mon Sep 17 00:00:00 2001 From: Cuvii Date: Thu, 22 Jan 2026 10:35:01 +0800 Subject: [PATCH 04/10] refactor: clean up imports in layout and page components - Removed unused `SearchDialog` import from `layout.tsx` to streamline the code. - Deleted the `dynamic` export from `page.tsx`, as it is no longer necessary for static rendering. --- src/app/[[...slug]]/page.tsx | 2 -- src/app/layout.tsx | 1 - 2 files changed, 3 deletions(-) diff --git a/src/app/[[...slug]]/page.tsx b/src/app/[[...slug]]/page.tsx index 532b15b..9f158f1 100644 --- a/src/app/[[...slug]]/page.tsx +++ b/src/app/[[...slug]]/page.tsx @@ -12,8 +12,6 @@ import { source } from "@/lib/source"; import { getMDXComponents } from "@/mdx-components"; import { A } from "@/modules/mdx-components/a"; -export const dynamic = 'force-static'; - export default async function Page(props: PageProps<"/[[...slug]]">) { const params = await props.params; const page = source.getPage(params.slug); diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 46b682c..bbdf2ac 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -5,7 +5,6 @@ import { Inter } from "next/font/google"; import { cn } from "@/lib/cn"; import { source } from "@/lib/source"; import { DocsLayout } from "@/components/layout/docs"; -import { SearchDialog } from "fumadocs-ui/components/dialog/search"; import { DefaultSearchDialog } from "@/components/search"; const inter = Inter({ From fd97189131e75e009faea1f8c63d6e21ee87b237 Mon Sep 17 00:00:00 2001 From: Cuvii Date: Thu, 22 Jan 2026 10:39:05 +0800 Subject: [PATCH 05/10] refactor: simplify development server command in package.json - Removed the port specification from the development server command in `package.json` to streamline the setup process. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index facc04b..068de0d 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "build": "next build", - "dev": "next dev --turbo -p 3001", + "dev": "next dev --turbo", "start": "next start", "postinstall": "fumadocs-mdx", "preview": "opennextjs-cloudflare build && opennextjs-cloudflare preview", From 77a6d796a91f024eea01769f9cd291ae639f308b Mon Sep 17 00:00:00 2001 From: Cuvii Date: Thu, 22 Jan 2026 10:43:55 +0800 Subject: [PATCH 06/10] refactor: streamline static parameter generation and update development server command - Simplified the `generateStaticParams` function in `page.tsx` to directly return parameters from the source, enhancing clarity. - Updated the development server command in `package.json` to specify port 3001 for improved accessibility. --- package.json | 2 +- src/app/[[...slug]]/page.tsx | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 068de0d..facc04b 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "build": "next build", - "dev": "next dev --turbo", + "dev": "next dev --turbo -p 3001", "start": "next start", "postinstall": "fumadocs-mdx", "preview": "opennextjs-cloudflare build && opennextjs-cloudflare preview", diff --git a/src/app/[[...slug]]/page.tsx b/src/app/[[...slug]]/page.tsx index 9f158f1..e6bd018 100644 --- a/src/app/[[...slug]]/page.tsx +++ b/src/app/[[...slug]]/page.tsx @@ -38,15 +38,8 @@ export default async function Page(props: PageProps<"/[[...slug]]">) { ); } -export async function generateStaticParams() { - const params = source.generateParams(); - - // For optional catch-all routes with static export, we must include the root path - // Filter out any existing root paths to avoid duplicates - const filteredParams = params.filter((p) => p.slug && p.slug.length > 0); - - // Return root path first, then all other paths - return [{ slug: [] }, ...filteredParams]; +export function generateStaticParams() { + return source.generateParams(); } export async function generateMetadata( From e0be5e0642c312bb0259599a39e59fb2a0edf87b Mon Sep 17 00:00:00 2001 From: Cuvii Date: Thu, 22 Jan 2026 10:56:51 +0800 Subject: [PATCH 07/10] refactor: enhance static parameter generation in page.tsx - Updated the `generateStaticParams` function to include a root path entry, ensuring proper handling of the root path alongside parameters generated from the source. --- src/app/[[...slug]]/page.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/[[...slug]]/page.tsx b/src/app/[[...slug]]/page.tsx index e6bd018..8ff0a16 100644 --- a/src/app/[[...slug]]/page.tsx +++ b/src/app/[[...slug]]/page.tsx @@ -39,7 +39,10 @@ export default async function Page(props: PageProps<"/[[...slug]]">) { } export function generateStaticParams() { - return source.generateParams(); + return [ + { slug: [] }, // Handle root path + ...source.generateParams() + ] } export async function generateMetadata( From 6876a20434c7a230845e7990ee710a7a457d1919 Mon Sep 17 00:00:00 2001 From: Cuvii Date: Thu, 22 Jan 2026 10:57:45 +0800 Subject: [PATCH 08/10] refactor: simplify Heading component rendering logic - Streamlined the rendering logic in the `Heading` component by consolidating the anchor link creation and default properties into a single `useRender` call, enhancing code clarity and maintainability. --- src/modules/mdx-components/heading.tsx | 35 ++++++++++++++------------ 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/modules/mdx-components/heading.tsx b/src/modules/mdx-components/heading.tsx index 3187f1b..45ca8c2 100644 --- a/src/modules/mdx-components/heading.tsx +++ b/src/modules/mdx-components/heading.tsx @@ -6,26 +6,29 @@ import { useRender } from "@base-ui/react/use-render"; interface HeadingProps extends useRender.ComponentProps<"h1"> {} export function Heading(props: HeadingProps) { - const { render, children, id, ...otherProps } = props; - - const headingContent = id ? ( - - {children} - - ) : ( - children - ); - - const defaultProps: useRender.ElementProps<"h1"> = { - className: - "text-text-high font-semibold tracking-tight font-mono leading-[140%]", - children: headingContent, - }; + const { render, children, ...otherProps } = props; const element = useRender({ defaultTagName: "h1", render, - props: mergeProps<"h1">(defaultProps, otherProps), + props: mergeProps( + { + className: + "text-text-high font-semibold tracking-tight font-mono leading-[140%]", + children: ( + <> + {props.id ? ( + + {props.children} + + ) : ( + props.children + )} + + ), + }, + otherProps, + ), }); return element; From 0347f62cfebe8ab1a1e40c13d39e48b286be2504 Mon Sep 17 00:00:00 2001 From: Cuvii Date: Thu, 22 Jan 2026 10:58:51 +0800 Subject: [PATCH 09/10] refactor: update development server command in package.json - Removed the port specification from the development server command in `package.json` to simplify the setup process. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index facc04b..068de0d 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "build": "next build", - "dev": "next dev --turbo -p 3001", + "dev": "next dev --turbo", "start": "next start", "postinstall": "fumadocs-mdx", "preview": "opennextjs-cloudflare build && opennextjs-cloudflare preview", From d61cb9adcbcc0ae47dd2d258305303a02e7b6668 Mon Sep 17 00:00:00 2001 From: Cuvii Date: Thu, 22 Jan 2026 11:28:36 +0800 Subject: [PATCH 10/10] refactor: simplify SidebarItem component by removing prefetch prop - Eliminated the unused `prefetch` prop in the `SidebarItem` component, enhancing code clarity and reducing unnecessary complexity. --- src/components/layout/sidebar/base.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/layout/sidebar/base.tsx b/src/components/layout/sidebar/base.tsx index 8cd7b8a..f4d9c24 100644 --- a/src/components/layout/sidebar/base.tsx +++ b/src/components/layout/sidebar/base.tsx @@ -269,14 +269,13 @@ export function SidebarItem({ }) { const pathname = usePathname(); const ref = useRef(null); - const { prefetch } = useSidebar(); const active = - props.href !== undefined && isActive(props.href, pathname, false); - + props.href !== undefined && isActive(props.href, pathname, false); + useAutoScroll(active, ref); return ( - + {icon ?? (props.external ? : null)} {children}