diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-02-28 23:58:54 +0100 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-02-28 23:58:54 +0100 |
| commit | 85f41756d18d586377823eaac26117f3c8ccb9ba (patch) | |
| tree | 11111a4b58ad424f96bea85f8f57912b0df4f1a6 /apps/web/content-collections.ts | |
| parent | fe964c4a4a1ead39227b506f28f044f6e914f09e (diff) | |
| download | opencut-85f41756d18d586377823eaac26117f3c8ccb9ba.tar.gz | |
feat: changelog page
Diffstat (limited to 'apps/web/content-collections.ts')
| -rw-r--r-- | apps/web/content-collections.ts | 32 |
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], +}); |
