Skip to content

Commit f620410

Browse files
fix missing mobile menu in 404 page (#2227)
## Description - Removed MenuProvider wrapper and implement custom useMenu hook with useSyncExternalStore - Added missing sidebar to main layout for 404 page - Patched Nextra Theme Docs again to show the same sidebar and use the same layout wrapper in all pages in Pages router (previously Nextra used the default wrapper for layout=raw, so we had two subtly different sidebars) - Fixed "Registeration" typo --------- Co-authored-by: Jonathan Brennan <jonathanawesome@users.noreply.github.com>
1 parent bd76c82 commit f620410

File tree

15 files changed

+137
-86
lines changed

15 files changed

+137
-86
lines changed

patches/nextra-theme-docs.patch

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ index 71f87bcd1dde49d7c19ad49fc098e715a76c5c10..a0b8143b6b7ef89513c2199b956f5f87
3636
+ flatDocsDirectories: Item[]
3737
+}
3838
diff --git a/dist/index.js b/dist/index.js
39-
index 56201641fd965dcc5ab7c5df53e444c41293c00e..71f4d353b5bd6c0fcab630330f578b5593f8596e 100644
39+
index 56201641fd965dcc5ab7c5df53e444c41293c00e..cb6682bf947351f5757f51b43ff85237f16f1096 100644
4040
--- a/dist/index.js
4141
+++ b/dist/index.js
4242
@@ -100,10 +100,10 @@ IntersectionObserverContext.displayName = "IntersectionObserver";
@@ -125,3 +125,12 @@ index 56201641fd965dcc5ab7c5df53e444c41293c00e..71f4d353b5bd6c0fcab630330f578b55
125125
body
126126
] })
127127
}
128+
@@ -2524,7 +2485,7 @@ function getComponents({
129+
components
130+
}) {
131+
if (isRawLayout) {
132+
- return { a: A, wrapper: DEFAULT_COMPONENTS.wrapper };
133+
+ return { a: A, wrapper: components.wrapper };
134+
}
135+
const context = { index: 0 };
136+
return __spreadValues(__spreadProps(__spreadValues({}, DEFAULT_COMPONENTS), {

patches/nextra.patch

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ index 9d05118d3d10e746cd2c020785a0f34465bb8570..218107600d7efed1b5f9d49f0a696b16
2020
Playground,
2121
Popup,
2222
Pre,
23+
diff --git a/dist/client/hooks/use-fs-route.js b/dist/client/hooks/use-fs-route.js
24+
index 7948959d9c044d66e241864789454e0ea637c659..46e352a845c3776965f3f1957e5d93b946444a3a 100644
25+
--- a/dist/client/hooks/use-fs-route.js
26+
+++ b/dist/client/hooks/use-fs-route.js
27+
@@ -1,9 +1,9 @@
28+
-import { useRouter } from "next/router";
29+
+import { useRouter } from "next/compat/router";
30+
import { useMemo } from "react";
31+
import { DEFAULT_LOCALE, ERROR_ROUTES } from "../../constants.js";
32+
const template = "https://nextra.site";
33+
const useFSRoute = () => {
34+
- const { locale = DEFAULT_LOCALE, asPath, route } = useRouter();
35+
+ const { locale = DEFAULT_LOCALE, asPath, route } = useRouter() || {};
36+
return useMemo(() => {
37+
const clientRoute = ERROR_ROUTES.has(route) ? route : asPath;
38+
const { pathname } = new URL(clientRoute, template);
2339
diff --git a/dist/client/normalize-pages.js b/dist/client/normalize-pages.js
2440
index 15afee0c1de26f47d781f423e5ec32e33ad925d3..fefd01736bd2b778df275bf50ac48384d5f63845 100644
2541
--- a/dist/client/normalize-pages.js

pnpm-lock.yaml

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/(main)/layout.tsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ import { ThemeProvider } from "next-themes"
44
import { Footer } from "../../components/footer"
55
import { NewFontsStyleTag } from "../fonts"
66
import { Navbar } from "../../components/navbar/navbar"
7-
import { topLevelNavbarItems } from "../../components/navbar/top-level-items"
8-
import { MenuProvider } from "./menu-provider"
7+
import {
8+
directories,
9+
docsDirectories,
10+
topLevelNavbarItems,
11+
} from "../../components/navbar/top-level-items"
12+
import { Sidebar } from "../../components/sidebar"
913

1014
export default function MainLayout({
1115
children,
@@ -16,13 +20,18 @@ export default function MainLayout({
1620
<>
1721
<NewFontsStyleTag />
1822
<ThemeProvider attribute="class">
19-
<MenuProvider>
20-
<Navbar items={topLevelNavbarItems} />
21-
<div className="isolate bg-neu-0 text-neu-900 antialiased">
22-
{children}
23-
</div>
24-
<Footer />
25-
</MenuProvider>
23+
<Navbar items={topLevelNavbarItems} />
24+
<Sidebar
25+
includePlaceholder={false}
26+
toc={[]}
27+
docsDirectories={docsDirectories}
28+
fullDirectories={directories}
29+
asPopover
30+
/>
31+
<div className="isolate bg-neu-0 text-neu-900 antialiased">
32+
{children}
33+
</div>
34+
<Footer />
2635
</ThemeProvider>
2736
</>
2837
)

src/app/(main)/menu-provider.tsx

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/app/conf/2025/components/register-today/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function RegisterToday({ className }: RegisterTodayProps) {
3838
</div>
3939
<div className="mt-10 flex gap-x-6 gap-y-4 max-sm:flex-col">
4040
<Button disabled className="opacity-55" href={GET_TICKETS_LINK}>
41-
Registeration closed
41+
Registration closed
4242
</Button>
4343
<Button
4444
disabled

src/components/navbar/navbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import NextLink from "next/link"
88
import { Button } from "nextra/components"
99
import type * as normalizePages from "nextra/normalize-pages"
1010
import React, { useEffect, type ReactElement, type ReactNode } from "react"
11-
import { useMenu } from "nextra-theme-docs"
1211
import { Anchor } from "@/app/conf/_design-system/anchor"
1312

1413
import MenuIcon from "@/app/conf/_design-system/pixelarticons/menu.svg?svgr"
@@ -17,6 +16,7 @@ import { GraphQLWordmarkLogo } from "../../icons"
1716
import { ThemeSwitch } from "../theme-switch"
1817
import { Flexsearch } from "../flexsearch"
1918
import { NavLink, navLinkClasses } from "./nav-link"
19+
import { useMenu } from "../use-menu"
2020

2121
type Item = normalizePages.PageItem | normalizePages.MenuItem
2222
export interface NavBarProps {

src/components/navbar/top-level-items.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ export function normalizeMetaToItems(meta: Record<string, any>, parent = "/") {
4747
return result
4848
}
4949

50-
export const { topLevelNavbarItems } = normalizeMetaToItems(meta)
50+
export const { topLevelNavbarItems, docsDirectories, directories } =
51+
normalizeMetaToItems(meta)

src/components/nextra-mdx-wrapper.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export function NextraMdxWrapper({
4949
<TableOfContents toc={toc} filePath={config.filePath} />
5050
</nav>
5151
)
52+
5253
return (
5354
<div
5455
className={clsx(

0 commit comments

Comments
 (0)