mirror of
https://github.com/hanzoai/zod.git
synced 2026-09-24 17:04:49 +00:00
* Fix File reference issues. Fixes #4880. Fixes #4933. * Relax metadata constraint to object. Fixes #4929 * Clean up partialRecord implementation. Closes #4882. * Fixes catch handling in object schemas. Fixes #4883. * Add treeshake case * Document optionality changes * Fix docs build * Do not return empty metadata objects. Fixed #4885 * Escape non-string literal patterns. Closes #4894 * Surface continuable errors preferentially in unions. Fixes #4896 * Drop private modifier. Fixes #4903 * Simplify object parsing. Closes #4900 * Clean up .caught * Make message a non-getter. Closes #4901. * Standardize behavior of transform and preprocess. Closes #4910 * Clean up docs * Fix extend for recursive objects. Fixes #4931 * Make object methods work with recursive types. Closes #4931 again * Improve laziness of object methods * Make standardschema FailureResult work with prettifyError. Closes #4914. * Do not use normalized URLs by default. Add normalize flag to ZodURL. Closes #4906 * Tweak URL docs. Closes #4959 * 4.0.6
106 lines
3.1 KiB
TypeScript
106 lines
3.1 KiB
TypeScript
import { Heading } from "@/components/heading";
|
|
import { Tabs } from "@/components/tabs";
|
|
import { source } from "@/loaders/source";
|
|
import { Callout } from "fumadocs-ui/components/callout";
|
|
import defaultMdxComponents, { createRelativeLink } from "fumadocs-ui/mdx";
|
|
import { DocsBody, DocsDescription, DocsPage, DocsTitle } from "fumadocs-ui/page";
|
|
import { notFound } from "next/navigation";
|
|
|
|
export const revalidate = 86400;
|
|
|
|
export default async function Page(props: {
|
|
params: Promise<{ slug?: string[] }>;
|
|
}) {
|
|
const params = await props.params;
|
|
const page = source.getPage(params.slug);
|
|
if (!page) notFound();
|
|
|
|
const title = page.data.title;
|
|
const description = page.data.description;
|
|
|
|
const MDXContent = page.data.body;
|
|
const toc = page.data.toc
|
|
.filter((item) => item.depth <= 3)
|
|
.map((item) => {
|
|
return item;
|
|
});
|
|
|
|
return (
|
|
<DocsPage
|
|
toc={toc}
|
|
tableOfContent={{ style: "clerk", single: false }}
|
|
full={false}
|
|
editOnGithub={{
|
|
owner: "colinhacks",
|
|
repo: "zod",
|
|
sha: "v4",
|
|
path: `packages/docs/content/${page.file.path}`,
|
|
}}
|
|
>
|
|
{title && title !== "Intro" ? <DocsTitle>{title}</DocsTitle> : null}
|
|
<DocsDescription>{description}</DocsDescription>
|
|
<DocsBody {...{}}>
|
|
<MDXContent
|
|
components={{
|
|
...defaultMdxComponents,
|
|
// this allows you to link to other pages with relative file paths
|
|
a: createRelativeLink(source, page),
|
|
// you can add other MDX components here
|
|
blockquote: Callout,
|
|
Tabs,
|
|
h1: (props: any) => <Heading as="h1" {...props} />,
|
|
h2: (props: any) => <Heading as="h2" {...props} />,
|
|
h3: (props: any) => <Heading as="h3" {...props} />,
|
|
h4: (props: any) => <Heading as="h4" {...props} />,
|
|
h5: (props: any) => <Heading as="h5" {...props} />,
|
|
h6: (props: any) => <Heading as="h6" {...props} />,
|
|
}}
|
|
/>
|
|
</DocsBody>
|
|
</DocsPage>
|
|
);
|
|
}
|
|
|
|
export async function generateStaticParams() {
|
|
return source.generateParams();
|
|
}
|
|
|
|
export async function generateMetadata(props: {
|
|
params: Promise<{ slug?: string[] }>;
|
|
}) {
|
|
const params = await props.params;
|
|
const page = source.getPage(params.slug);
|
|
if (!page) notFound();
|
|
|
|
const rootTitle = page.data.title ?? "Home";
|
|
const title = rootTitle + " | Zod";
|
|
const description = page.data.description;
|
|
return {
|
|
title,
|
|
description,
|
|
openGraph: {
|
|
type: "website",
|
|
title,
|
|
description,
|
|
siteName: "Zod",
|
|
url: `https://zod.dev/${page.slugs.join("/")}`,
|
|
images: [
|
|
{
|
|
url: `/og.png?title=${encodeURIComponent(rootTitle)}&description=${encodeURIComponent(description ?? "")}&path=${encodeURIComponent(`${["zod.dev", ...page.slugs].join("/")}`)}`,
|
|
width: 1200,
|
|
height: 630,
|
|
alt: title,
|
|
},
|
|
],
|
|
},
|
|
twitter: {
|
|
card: "summary_large_image",
|
|
title,
|
|
description,
|
|
creator: "@colinhacks",
|
|
site: "@colinhacks",
|
|
},
|
|
keywords: ["zod", "typescript", "validation", "schema"],
|
|
};
|
|
}
|