Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Warning for $schema for docs.json #401

Open
wants to merge 4 commits into
base: next
Choose a base branch
from
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
3 changes: 3 additions & 0 deletions api/src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Binary file modified bun.lockb
Binary file not shown.
18 changes: 11 additions & 7 deletions website/src/components/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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;
Expand Down
53 changes: 33 additions & 20 deletions website/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 ? <ChevronUpIcon size={14} /> : <ChevronDownIcon size={14} />
}
Expand All @@ -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 ? (
<Link
href={href}
onClick={props.collapse ? props.onClick : undefined}
onClick={props.collapse && !props.isOpen ? props.onClick : undefined}
className={cn(className, {
"nav-link-active": isActive,
})}
style={style}
/>
) : (
<div
role="button"
className={className}
style={style}
onKeyDown={props.onClick}
onClick={props.onClick}
/>
Expand All @@ -173,26 +182,30 @@ function SidebarAnchor(props: {
<Icon key="icon" name={props.icon} />
</span>
) : null,
<span key="title" className="flex-1">
<span key="title" className="flex-1 text-ellipsis overflow-hidden">
{props.title}
</span>,
props.collapse ? (
<div key="toggle" onKeyDown={props.onClick} onClick={props.onClick}>
{props.collapse}
</div>
) : null,
]);

return (
<div className="opacity-75 has-[.nav-link-active]:opacity-100 hover:opacity-100 mb-px relative rounded-md hover:bg-black/5 dark:hover:bg-white/5 has-[.nav-link-active]:bg-primary-light/10 dark:has-[.nav-link-active]:bg-primary-light/10 dark:hover:has-[.nav-link-active]:bg-primary-light/10 transition-all">
<div
className="has-[.nav-link-active]:font-bold has-[.nav-link-active]:text-primary-light dark:has-[.nav-link-active]:text-primary-light"
style={{
paddingLeft: `${props.depth * 12}px`,
}}
>
{anchor}
</div>
<div
className={cn(
"flex opacity-75 hover:opacity-100 mb-px relative rounded-md hover:bg-black/5 dark:hover:bg-white/5 transition-all has-[.nav-link-active]:font-bold",
"has-[.nav-link-active]:opacity-100 has-[.nav-link-active]:bg-primary-light/10 dark:has-[.nav-link-active]:bg-primary-light/10 dark:hover:has-[.nav-link-active]:bg-primary-light/10 has-[.nav-link-active]:text-primary-light dark:has-[.nav-link-active]:text-primary-light"
)}
>
{anchor}
{props.collapse ? (
<button
key="toggle"
type="button"
onKeyDown={props.onClick}
onClick={props.onClick}
className="px-3"
>
{props.collapse}
</button>
) : null}
</div>
);
}
Loading