summaryrefslogtreecommitdiff
path: root/apps/web/content-collections.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/content-collections.ts')
-rw-r--r--apps/web/content-collections.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/apps/web/content-collections.ts b/apps/web/content-collections.ts
new file mode 100644
index 00000000..b3028846
--- /dev/null
+++ b/apps/web/content-collections.ts
@@ -0,0 +1,32 @@
+import { defineCollection, defineConfig } from "@content-collections/core";
+import { z } from "zod";
+
+const changelog = defineCollection({
+ name: "changelog",
+ directory: "content/changelog",
+ include: "*.md",
+ schema: z.object({
+ version: z.string(),
+ date: z.string(),
+ title: z.string(),
+ description: z.string().optional(),
+ changes: z.array(
+ z.object({
+ type: z.string(),
+ text: z.string(),
+ }),
+ ),
+ }),
+ transform: async (doc, { collection }) => {
+ const allDocs = await collection.documents();
+ const sorted = [...allDocs].sort((a, b) =>
+ b.version.localeCompare(a.version, undefined, { numeric: true }),
+ );
+ const isLatest = sorted[0]?.version === doc.version;
+ return { ...doc, isLatest };
+ },
+});
+
+export default defineConfig({
+ content: [changelog],
+});