import { z } from "astro/zod"; import { LANGUAGE_KEYS } from "./constants"; export const LinkSchema = z .object({ type: z.custom<"source" | "website" | (string & {})>( (val) => typeof val === "string", ), label: z.string(), href: z.url(), }) .transform((link) => ({ ...link, type: link.type as "source" | "website" | (string & {}), })); export type Link = z.infer; export const ProjectSchema = z.object({ name: z.string(), description: z.string(), /** if true, link will not be rendered to its page */ stub: z.boolean(), links: z.array(LinkSchema), languages: z.array(z.enum(LANGUAGE_KEYS)), }); export type Project = z.infer;