Skip to content
Closed
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
33 changes: 33 additions & 0 deletions src/components/docs/docs-sidebar-trigger.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use client';

import { useSidebar } from 'fumadocs-ui/contexts/sidebar';
import { PanelLeft } from 'lucide-react';
import { usePathname } from 'next/navigation';

import { cn } from '@/lib/utils';

// Docs section layouts disable fumadocs's mobile nav (to avoid duplicating
// the site Navbar), which also removes fumadocs's built-in SidebarTrigger.
// This re-exposes that trigger inside the site Navbar on /docs routes,
// only at viewports below `md` (where the desktop sidebar is hidden).
export function DocsSidebarTrigger({ className }: { className?: string }) {
const pathname = usePathname();
const { open, setOpen } = useSidebar();

if (!pathname.startsWith('/docs')) return null;

return (
<button
type="button"
aria-label="Toggle docs navigation"
aria-expanded={open}
onClick={() => setOpen(!open)}
className={cn(
'text-muted-foreground hover:text-foreground relative flex size-8 items-center justify-center rounded-sm border md:hidden',
className,
)}
>
<PanelLeft className="size-4" />
</button>
);
}
2 changes: 2 additions & 0 deletions src/components/layout/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import Link from 'next/link';
import { usePathname } from 'next/navigation';
import React, { useEffect, useState } from 'react';

import { DocsSidebarTrigger } from '@/components/docs/docs-sidebar-trigger';
import Logo from '@/components/layout/logo';
import { ThemeToggle } from '@/components/theme-toggle';
import {
Expand Down Expand Up @@ -681,6 +682,7 @@ const Navbar = () => {
</div>

<div className="flex items-center gap-2 lg:hidden lg:gap-4">
<DocsSidebarTrigger />
<ThemeToggle />
<button
className="text-muted-foreground relative flex size-8 rounded-sm border lg:hidden"
Expand Down