Files
eu/lib/pages/types.ts
T

59 lines
1.6 KiB
TypeScript

export const PAGE_TYPES = ["NEWS", "PAGE"] as const;
export type PageType = typeof PAGE_TYPES[number];
export const PAGE_STATUSES = ["DRAFT", "PUBLISHED", "ARCHIVED"] as const;
export type PageStatus = typeof PAGE_STATUSES[number];
export type PageMeta = {
tags?: string[];
location?: string;
}
export type Page = {
id: string;
slug: string;
title: string;
type: PageType;
status: PageStatus;
meta: PageMeta;
createdAt: Date;
updatedAt: Date;
publishedAt: Date | null;
createdBy: string | null;
updatedBy: string | null;
}
export type PagePublic = {
id: string;
slug: string;
title: string;
type: PageType;
status: PageStatus;
meta: PageMeta;
createdAt: Date;
updatedAt: Date;
publishedAt: Date | null;
}
export const BLOCK_TYPES = ["PARAGRAPH", "HEADING", "QUOTE", "DIVIDER", "CALLOUT", "IMAGE", "LIST", "TABLE", "LINK"] as const;
export type BlockType = typeof BLOCK_TYPES[number];
export type BlockContent =
| { type: "PARAGRAPH"; text: string }
| { type: "HEADING"; text: string; level: 1 | 2 | 3 }
| { type: "QUOTE"; text: string; author?: string }
| { type: "DIVIDER" }
| { type: "CALLOUT"; title: string; text: string }
| { type: "IMAGE"; url: string; caption?: string }
| { type: "LIST"; style: "BULLET" | "ORDERED"; items: string[] }
| { type: "TABLE"; headers: string[]; rows: string[][] }
| { type: "LINK"; label: string; href: string }
export type Block = {
id: string;
pageId: string;
parentId: string | null;
type: BlockType;
position: number;
content: BlockContent;
}