23 lines
617 B
TypeScript
23 lines
617 B
TypeScript
import { z } from "zod";
|
|
import { fileType } from "./file";
|
|
|
|
const baseItem = z.object({
|
|
path: z.string(),
|
|
parent: z.string(),
|
|
name: z.string(),
|
|
title: z.string(),
|
|
type: fileType,
|
|
navigable: z.boolean(),
|
|
private: z.boolean(),
|
|
order: z.number().finite(),
|
|
content: z.string().optional().or(z.null()),
|
|
});
|
|
export const item: z.ZodType<ProjectItem> = baseItem.extend({
|
|
children: z.lazy(() => item.array().optional()),
|
|
});
|
|
export const project = z.array(item);
|
|
|
|
type Project = z.infer<typeof project>;
|
|
type ProjectItem = z.infer<typeof baseItem> & {
|
|
children?: ProjectItem[]
|
|
};
|