30 lines
816 B
TypeScript
30 lines
816 B
TypeScript
import { z } from "zod";
|
|
|
|
export const pageStatusSchema = z.enum(["draft", "published"]);
|
|
|
|
export const heroSchema = z.object({
|
|
heading: z.string().min(1).max(255),
|
|
subheading: z.string().optional(),
|
|
imageId: z.string().optional(),
|
|
});
|
|
|
|
export const pageSchema = z.object({
|
|
id: z.string(),
|
|
title: z.string().min(1).max(255),
|
|
slug: z.string().min(1).max(255),
|
|
hero: heroSchema,
|
|
layout: z.array(z.unknown()),
|
|
status: pageStatusSchema.default("draft"),
|
|
publishedAt: z.date().nullable().default(null),
|
|
seo: z.object({
|
|
title: z.string().min(1),
|
|
description: z.string().optional(),
|
|
}),
|
|
createdAt: z.date(),
|
|
updatedAt: z.date(),
|
|
});
|
|
|
|
export type Page = z.infer<typeof pageSchema>;
|
|
export type PageStatus = z.infer<typeof pageStatusSchema>;
|
|
export type Hero = z.infer<typeof heroSchema>;
|