all repos — websitemeow @ 7685833af780d9105bbc4bb6d9e188b51358eabf

src/types.ts (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
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<typeof LinkSchema>;

export const ProjectSchema = z.object({
	name: z.string(),
	description: z.string(),
	/** if true, link will not be rendered to its page */
	stub: z.boolean(),
	pinned: z.boolean().default(false).optional(),

	links: z.array(LinkSchema),
	languages: z.array(z.enum(LANGUAGE_KEYS)),
});
export type Project = z.infer<typeof ProjectSchema>;

export const DiscordMessageSchema = z.object({
	author: z.string(),
	avatarUrl: z.string(),
	content: z.array(z.string()),
	timestamp: z.string(),
});
export type DiscordMessage = z.infer<typeof DiscordMessageSchema>;