From 3f04fae9d8cc584fa136dc8bb73ef57ce4104be6 Mon Sep 17 00:00:00 2001 From: Piotr Monwid-Olechnowicz Date: Mon, 10 Nov 2025 13:21:53 +0100 Subject: [PATCH 1/8] Stop relying on Nextra's MenuProvider --- patches/nextra-theme-docs.patch | 11 ++++++- patches/nextra.patch | 16 ++++++++++ pnpm-lock.yaml | 14 ++++----- src/app/(main)/layout.tsx | 16 +++++++--- src/app/(main)/menu-provider.tsx | 9 ------ src/components/navbar/navbar.tsx | 2 +- src/components/navbar/top-level-items.tsx | 2 +- src/components/nextra-mdx-wrapper.tsx | 1 + .../{sidebar.tsx => sidebar/index.tsx} | 31 ++++--------------- src/components/use-menu.tsx | 24 ++++++++++++++ src/nextra-theme-docs.css | 9 ++++++ src/pages/_app.tsx | 6 ++++ 12 files changed, 93 insertions(+), 48 deletions(-) delete mode 100644 src/app/(main)/menu-provider.tsx rename src/components/{sidebar.tsx => sidebar/index.tsx} (94%) create mode 100644 src/components/use-menu.tsx diff --git a/patches/nextra-theme-docs.patch b/patches/nextra-theme-docs.patch index b9593db463..01f9b028ea 100644 --- a/patches/nextra-theme-docs.patch +++ b/patches/nextra-theme-docs.patch @@ -36,7 +36,7 @@ index 71f87bcd1dde49d7c19ad49fc098e715a76c5c10..a0b8143b6b7ef89513c2199b956f5f87 + flatDocsDirectories: Item[] +} diff --git a/dist/index.js b/dist/index.js -index 56201641fd965dcc5ab7c5df53e444c41293c00e..71f4d353b5bd6c0fcab630330f578b5593f8596e 100644 +index 56201641fd965dcc5ab7c5df53e444c41293c00e..cb6682bf947351f5757f51b43ff85237f16f1096 100644 --- a/dist/index.js +++ b/dist/index.js @@ -100,10 +100,10 @@ IntersectionObserverContext.displayName = "IntersectionObserver"; @@ -125,3 +125,12 @@ index 56201641fd965dcc5ab7c5df53e444c41293c00e..71f4d353b5bd6c0fcab630330f578b55 body ] }) } +@@ -2524,7 +2485,7 @@ function getComponents({ + components + }) { + if (isRawLayout) { +- return { a: A, wrapper: DEFAULT_COMPONENTS.wrapper }; ++ return { a: A, wrapper: components.wrapper }; + } + const context = { index: 0 }; + return __spreadValues(__spreadProps(__spreadValues({}, DEFAULT_COMPONENTS), { diff --git a/patches/nextra.patch b/patches/nextra.patch index 88ae4a7082..77d86c5c4c 100644 --- a/patches/nextra.patch +++ b/patches/nextra.patch @@ -20,6 +20,22 @@ index 9d05118d3d10e746cd2c020785a0f34465bb8570..218107600d7efed1b5f9d49f0a696b16 Playground, Popup, Pre, +diff --git a/dist/client/hooks/use-fs-route.js b/dist/client/hooks/use-fs-route.js +index 7948959d9c044d66e241864789454e0ea637c659..46e352a845c3776965f3f1957e5d93b946444a3a 100644 +--- a/dist/client/hooks/use-fs-route.js ++++ b/dist/client/hooks/use-fs-route.js +@@ -1,9 +1,9 @@ +-import { useRouter } from "next/router"; ++import { useRouter } from "next/compat/router"; + import { useMemo } from "react"; + import { DEFAULT_LOCALE, ERROR_ROUTES } from "../../constants.js"; + const template = "https://nextra.site"; + const useFSRoute = () => { +- const { locale = DEFAULT_LOCALE, asPath, route } = useRouter(); ++ const { locale = DEFAULT_LOCALE, asPath, route } = useRouter() || {}; + return useMemo(() => { + const clientRoute = ERROR_ROUTES.has(route) ? route : asPath; + const { pathname } = new URL(clientRoute, template); diff --git a/dist/client/normalize-pages.js b/dist/client/normalize-pages.js index 15afee0c1de26f47d781f423e5ec32e33ad925d3..fefd01736bd2b778df275bf50ac48384d5f63845 100644 --- a/dist/client/normalize-pages.js diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 241d10e532..e6234b89f7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,10 +19,10 @@ patchedDependencies: hash: fccadc7038719bcf9dc12a573655719edaf7ea8246bd144c660191d05b38c637 path: patches/mermaid-isomorphic.patch nextra: - hash: 007f6fda5122c6f4de34daac1f8221aa57dbe7c97563f4f6144c5c5310b2b7c8 + hash: a4cb9ca39251906b7635817067482091dda31729230807c156358a0561ce2bcb path: patches/nextra.patch nextra-theme-docs: - hash: c25310b4430bc971f964edfe5e79740a63ed5681f13d12cb8632955647b92228 + hash: 2cafbb261163557a490b97bea35ce78a55af9ec0ae200e2545ad15543b1443e5 path: patches/nextra-theme-docs.patch importers: @@ -145,10 +145,10 @@ importers: version: 3.0.1(less-loader@12.3.0(less@4.4.1))(less@4.4.1)(next@14.2.33(@babel/core@7.28.3)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)) nextra: specifier: 3.3.1 - version: 3.3.1(patch_hash=007f6fda5122c6f4de34daac1f8221aa57dbe7c97563f4f6144c5c5310b2b7c8)(@types/react@18.3.26)(acorn@8.15.0)(next@14.2.33(@babel/core@7.28.3)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(typescript@5.9.3) + version: 3.3.1(patch_hash=a4cb9ca39251906b7635817067482091dda31729230807c156358a0561ce2bcb)(@types/react@18.3.26)(acorn@8.15.0)(next@14.2.33(@babel/core@7.28.3)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(typescript@5.9.3) nextra-theme-docs: specifier: 3.3.1 - version: 3.3.1(patch_hash=c25310b4430bc971f964edfe5e79740a63ed5681f13d12cb8632955647b92228)(next@14.2.33(@babel/core@7.28.3)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(nextra@3.3.1(patch_hash=007f6fda5122c6f4de34daac1f8221aa57dbe7c97563f4f6144c5c5310b2b7c8)(@types/react@18.3.26)(acorn@8.15.0)(next@14.2.33(@babel/core@7.28.3)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(typescript@5.9.3))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + version: 3.3.1(patch_hash=2cafbb261163557a490b97bea35ce78a55af9ec0ae200e2545ad15543b1443e5)(next@14.2.33(@babel/core@7.28.3)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(nextra@3.3.1(patch_hash=a4cb9ca39251906b7635817067482091dda31729230807c156358a0561ce2bcb)(@types/react@18.3.26)(acorn@8.15.0)(next@14.2.33(@babel/core@7.28.3)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(typescript@5.9.3))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) numbro: specifier: 2.5.0 version: 2.5.0 @@ -12209,7 +12209,7 @@ snapshots: - '@babel/core' - babel-plugin-macros - nextra-theme-docs@3.3.1(patch_hash=c25310b4430bc971f964edfe5e79740a63ed5681f13d12cb8632955647b92228)(next@14.2.33(@babel/core@7.28.3)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(nextra@3.3.1(patch_hash=007f6fda5122c6f4de34daac1f8221aa57dbe7c97563f4f6144c5c5310b2b7c8)(@types/react@18.3.26)(acorn@8.15.0)(next@14.2.33(@babel/core@7.28.3)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(typescript@5.9.3))(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + nextra-theme-docs@3.3.1(patch_hash=2cafbb261163557a490b97bea35ce78a55af9ec0ae200e2545ad15543b1443e5)(next@14.2.33(@babel/core@7.28.3)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(nextra@3.3.1(patch_hash=a4cb9ca39251906b7635817067482091dda31729230807c156358a0561ce2bcb)(@types/react@18.3.26)(acorn@8.15.0)(next@14.2.33(@babel/core@7.28.3)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(typescript@5.9.3))(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: '@headlessui/react': 2.2.9(react-dom@18.3.1(react@18.3.1))(react@18.3.1) clsx: 2.1.1 @@ -12217,13 +12217,13 @@ snapshots: flexsearch: 0.7.43 next: 14.2.33(@babel/core@7.28.3)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) next-themes: 0.4.6(react-dom@18.3.1(react@18.3.1))(react@18.3.1) - nextra: 3.3.1(patch_hash=007f6fda5122c6f4de34daac1f8221aa57dbe7c97563f4f6144c5c5310b2b7c8)(@types/react@18.3.26)(acorn@8.15.0)(next@14.2.33(@babel/core@7.28.3)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(typescript@5.9.3) + nextra: 3.3.1(patch_hash=a4cb9ca39251906b7635817067482091dda31729230807c156358a0561ce2bcb)(@types/react@18.3.26)(acorn@8.15.0)(next@14.2.33(@babel/core@7.28.3)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(typescript@5.9.3) react: 18.3.1 react-dom: 18.3.1(react@18.3.1) scroll-into-view-if-needed: 3.1.0 zod: 3.25.76 - nextra@3.3.1(patch_hash=007f6fda5122c6f4de34daac1f8221aa57dbe7c97563f4f6144c5c5310b2b7c8)(@types/react@18.3.26)(acorn@8.15.0)(next@14.2.33(@babel/core@7.28.3)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(typescript@5.9.3): + nextra@3.3.1(patch_hash=a4cb9ca39251906b7635817067482091dda31729230807c156358a0561ce2bcb)(@types/react@18.3.26)(acorn@8.15.0)(next@14.2.33(@babel/core@7.28.3)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(typescript@5.9.3): dependencies: '@formatjs/intl-localematcher': 0.5.10 '@headlessui/react': 2.2.9(react-dom@18.3.1(react@18.3.1))(react@18.3.1) diff --git a/src/app/(main)/layout.tsx b/src/app/(main)/layout.tsx index fefeb27741..0e4174b022 100644 --- a/src/app/(main)/layout.tsx +++ b/src/app/(main)/layout.tsx @@ -4,8 +4,12 @@ import { ThemeProvider } from "next-themes" import { Footer } from "../../components/footer" import { NewFontsStyleTag } from "../fonts" import { Navbar } from "../../components/navbar/navbar" -import { topLevelNavbarItems } from "../../components/navbar/top-level-items" -import { MenuProvider } from "./menu-provider" +import { + directories, + docsDirectories, + topLevelNavbarItems, +} from "../../components/navbar/top-level-items" +import { Sidebar } from "../../components/sidebar" export default function MainLayout({ children, @@ -16,13 +20,17 @@ export default function MainLayout({ <> - +
{children}