Skip to content

Open source CapCut alternative.

TypeScript

feat(site): add a SCHEDULED blog post status

David Lec75e7dabf50b
diff --git a/site/prisma/Blog.prisma b/site/prisma/Blog.prisma
index b7516465..328a1920 100644
--- a/site/prisma/Blog.prisma
+++ b/site/prisma/Blog.prisma
@@ -2,8 +2,11 @@
// and every image live in R2 under blog/<id>/ (src/lib/blog/keys.ts), so the
// article text is never in the repository or the database.
+// A SCHEDULED post goes live on its own once publishedAt passes; until then
+// the site treats it as a draft.
enum BlogPostStatus {
DRAFT
+ SCHEDULED
PUBLISHED
}
@@ -20,6 +23,7 @@ model BlogPost {
keywords String[] @default([])
featured Boolean @default(false)
// The date shown on the post and the one the list sorts by; set in the CMS.
+ // On a SCHEDULED post, the moment it goes live.
publishedAt DateTime?
// Shown as "Updated …" when later than publishedAt.
revisedAt DateTime?
diff --git a/site/src/lib/blog/read.ts b/site/src/lib/blog/read.ts
index 86b36181..c305945f 100644
--- a/site/src/lib/blog/read.ts
+++ b/site/src/lib/blog/read.ts
@@ -10,7 +10,7 @@ import { extractHeadings, type BlogHeading } from "@/lib/blog/headings";
import { blogBodyKey, blogImageUrl } from "@/lib/blog/keys";
import { prisma } from "@/lib/prisma";
import { getObject } from "@/cut/server/cloud/r2";
-import type { BlogPost } from "@/generated/prisma/client";
+import type { BlogPost, BlogPostStatus } from "@/generated/prisma/client";
export const BLOG_TAG = "blog";
export const blogPostTag = (slug: string) => `blog:${slug}`;
@@ -18,7 +18,7 @@ export const blogPostTag = (slug: string) => `blog:${slug}`;
export type BlogPostCard = {
id: string;
slug: string;
- status: "DRAFT" | "PUBLISHED";
+ status: BlogPostStatus;
title: string;
excerpt: string;
summary: string | null;