diff --git a/api/src/config/schema.ts b/api/src/config/schema.ts index 55662570..4f0d200e 100644 --- a/api/src/config/schema.ts +++ b/api/src/config/schema.ts @@ -17,6 +17,8 @@ export type { Sidebar } from "./models/sidebar"; export const ConfigSchema = z .object({ + // The URL of the schema file + $schema: z.string().url().optional().catch(undefined), // The name of the project name: z.string().min(1).optional().catch(undefined), // The description of the project @@ -54,6 +56,7 @@ export const ConfigSchema = z sidebar, }) .transform((config) => { + if (config.$schema) delete config.$schema; return { ...config, // Extract locales from the sidebar configuration diff --git a/bun.lockb b/bun.lockb index 18c59bb8..59f8ae1b 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/website/src/components/Content.tsx b/website/src/components/Content.tsx index a4f9c30a..bd90cb0f 100644 --- a/website/src/components/Content.tsx +++ b/website/src/components/Content.tsx @@ -57,7 +57,7 @@ export function Content() { const { default: MDX } = runSync( bundle.code, // @ts-expect-error - seems to be a bug in the types - { ...runtime }, + { ...runtime } ); return ( @@ -108,14 +108,18 @@ export function Content() { // Show the page title if the frontmatter or config has it enabled const showPageTitle = - Boolean(bundle.frontmatter.showPageTitle) || - Boolean(bundle.config.content?.showPageTitle) || - false; + bundle.frontmatter.showPageTitle === false + ? false + : Boolean(bundle.frontmatter.showPageTitle) || + Boolean(bundle.config.content?.showPageTitle) || + false; const showPageImage = - Boolean(bundle.frontmatter.showPageImage) || - Boolean(bundle.config.content?.showPageImage) || - false; + bundle.frontmatter.showPageImage === false + ? false + : Boolean(bundle.frontmatter.showPageImage) || + Boolean(bundle.config.content?.showPageImage) || + false; const title = bundle.frontmatter.title; const description = bundle.frontmatter.description; diff --git a/website/src/components/Sidebar.tsx b/website/src/components/Sidebar.tsx index 0ced995b..6977ed49 100644 --- a/website/src/components/Sidebar.tsx +++ b/website/src/components/Sidebar.tsx @@ -84,16 +84,18 @@ function SidebarGroup(props: { group: Pages[number] } & { depth: number }) { // A recursive function to determine if this group // has an active child link. If so, it is open. function hasActiveChild(pages: Pages): boolean { + let isActive = false; for (const page of pages) { if ("group" in page) { if (hasActiveChild(page.pages)) { - return true; + isActive = true; } } else if (page.href) { - return getHrefIsActive(ctx, router.asPath, page.href); + isActive = getHrefIsActive(ctx, router.asPath, page.href); } } - return false; + + return isActive; } // Determine if this group has an active child link. @@ -122,6 +124,7 @@ function SidebarGroup(props: { group: Pages[number] } & { depth: number }) { depth={props.depth} href={props.group.href} icon={props.group.icon} + isOpen={open} collapse={ open ? : } @@ -142,26 +145,32 @@ function SidebarGroup(props: { group: Pages[number] } & { depth: number }) { function SidebarAnchor(props: { title: string; depth: number; + isOpen?: boolean; href?: string; icon?: string; collapse?: ReactElement; onClick?: () => void; }) { const { href, isActive } = useHrefMeta(props.href ?? ""); - const className = cn("relative group flex items-center pr-5 gap-2 py-2 pl-3"); + const className = cn("py-2 inline-flex gap-2 grow"); + const style = { + paddingLeft: `${(props.depth + 1) * 12}px`, + }; const element = props.href ? ( ) : (
@@ -173,26 +182,30 @@ function SidebarAnchor(props: { ) : null, - + {props.title} , - props.collapse ? ( -
- {props.collapse} -
- ) : null, ]); return ( -
-
- {anchor} -
+
+ {anchor} + {props.collapse ? ( + + ) : null}
); }