feat: news

This commit is contained in:
Ivan Rezchikov
2026-06-20 18:30:39 +03:00
parent 674fd11aa9
commit 95fd6ae716
19 changed files with 886 additions and 159 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ export async function savePageAction(params: {
meta?: PageMeta
}) {
if (params.id) {
await updatePage(params.id, params.title, params.status, params.blocks, params.meta);
await updatePage(params.id, params.title, params.type, params.status, params.blocks, params.meta);
revalidatePath(`/${params.slug}`);
revalidatePath("/news");
} else {
+3 -8
View File
@@ -1,4 +1,4 @@
export const PAGE_TYPES = ["NEWS"] as const;
export const PAGE_TYPES = ["NEWS", "PAGE"] as const;
export type PageType = typeof PAGE_TYPES[number];
export const PAGE_STATUSES = ["DRAFT", "PUBLISHED", "ARCHIVED"] as const;
@@ -22,20 +22,15 @@ export type Page = {
createdBy: string;
}
export const BLOCK_TYPES = ["PARAGRAPH", "HEADING", "IMAGE", "FILE", "QUOTE", "DIVIDER", "TABLE", "CALLOUT", "LIST", "LINK"] as const;
export const BLOCK_TYPES = ["PARAGRAPH", "HEADING", "QUOTE", "DIVIDER", "CALLOUT"] 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: "IMAGE"; url: string; caption?: string }
| { type: "FILE"; url: string; name: string }
| { type: "QUOTE"; text: string; author?: string }
| { type: "DIVIDER" }
| { type: "TABLE"; headers: string[]; rows: string[][] }
| { type: "CALLOUT"; text: string; icon?: string; color?: string }
| { type: "LIST"; style: "BULLET" | "NUMBERED"; items: string[] }
| { type: "LINK"; text?: string; url: string };
| { type: "CALLOUT"; title: string; text: string }
export type Block = {
id: string;
+9
View File
@@ -3,4 +3,13 @@ import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
export function formatDate(date: Date | string | null | undefined): string {
if (!date) return "";
return new Intl.DateTimeFormat("en-GB", {
day: "numeric",
month: "long",
year: "numeric",
}).format(new Date(date));
}