Skip to content
Open
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
16 changes: 5 additions & 11 deletions src/app/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,11 @@ 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);

if (!hasRootPath) {
return [{ slug: undefined }, ...params];
}

return params;
export function generateStaticParams() {
return [
{ slug: [] }, // Handle root path
...source.generateParams()
]
}

export async function generateMetadata(
Expand Down
3 changes: 2 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Inter } from "next/font/google";
import { cn } from "@/lib/cn";
import { source } from "@/lib/source";
import { DocsLayout } from "@/components/layout/docs";
import { DefaultSearchDialog } from "@/components/search";

const inter = Inter({
subsets: ["latin"],
Expand Down Expand Up @@ -75,7 +76,7 @@ export default function Layout({ children }: LayoutProps<"/">) {
/>
</head>
<body className={cn("flex flex-col min-h-screen", inter.className)}>
<RootProvider theme={{ enabled: false }}>
<RootProvider theme={{ enabled: false }} search={{SearchDialog:DefaultSearchDialog}}>
<DocsLayout tree={source.pageTree}>
{children}
</DocsLayout>
Expand Down
7 changes: 3 additions & 4 deletions src/components/layout/sidebar/base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,13 @@ export function SidebarItem({
}) {
const pathname = usePathname();
const ref = useRef<HTMLAnchorElement>(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 (
<Link ref={ref} data-active={active} prefetch={prefetch} {...props}>
<Link ref={ref} data-active={active} {...props}>
{icon ?? (props.external ? <ExternalLink /> : null)}
{children}
</Link>
Expand Down
6 changes: 3 additions & 3 deletions src/components/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -40,8 +40,8 @@ export default function DefaultSearchDialog(props: SharedProps) {
<SearchDialogInput />
<SearchDialogClose />
</SearchDialogHeader>
<SearchDialogList items={query.data !== 'empty' ? query.data : null} />
<SearchDialogList items={query?.data !== 'empty' ? query.data : null} />
</SearchDialogContent>
</SearchDialog>
);
}
}