Add blog CMS with tracked public posts
Build Check / build (pull_request) Successful in 34s
Build Check / push-image (pull_request) Has been skipped
Build Check / deploy-coolify (pull_request) Has been skipped

This commit is contained in:
2026-07-17 22:02:25 +00:00
parent ef63164d58
commit 912e5edb81
24 changed files with 1667 additions and 36 deletions
+28
View File
@@ -111,3 +111,31 @@ export function parseAffiliate(body: Record<string, unknown>) {
sortIndex: int(body.sortIndex),
};
}
function slug(value: unknown): string {
const normalized = str(value, "slug")
.toLowerCase()
.replace(/[^a-z0-9]+/g, "-")
.replace(/^-+|-+$/g, "");
if (!normalized) {
throw new ValidationError('"slug" is invalid');
}
return normalized;
}
export function parseBlogPost(body: Record<string, unknown>) {
const isPublished = bool(body.isPublished);
const publishedAt = optDate(body.publishedAt);
return {
title: str(body.title, "title"),
slug: slug(body.slug),
excerpt: str(body.excerpt, "excerpt"),
coverImageUrl: optStr(body.coverImageUrl),
content: str(body.content, "content"),
isPublished,
publishedAt: isPublished ? publishedAt ?? new Date() : publishedAt,
};
}