From 9449d528f2c951c28cf169bca7e47e60b2690dfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20P=C4=99dzich?= Date: Sun, 3 Sep 2023 03:58:03 +0200 Subject: [PATCH] Introduce a dateAdded field in content config --- src/content/cats/maciejpedzich-placeholder.json | 1 + src/content/config.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/content/cats/maciejpedzich-placeholder.json b/src/content/cats/maciejpedzich-placeholder.json index 473989c..1d7b4ec 100644 --- a/src/content/cats/maciejpedzich-placeholder.json +++ b/src/content/cats/maciejpedzich-placeholder.json @@ -1,5 +1,6 @@ { "name": "Placeholder", + "dateAdded": "2023-09-02T18:50:00.066Z", "description": "This is a placeholder cat with a photo taken from placekitten.com", "image": { "src": "/images/maciejpedzich-placeholder.jpg", diff --git a/src/content/config.ts b/src/content/config.ts index 012ecc6..6f680bf 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -4,6 +4,10 @@ const cats = defineCollection({ type: 'data', schema: z.object({ name: z.string(), + dateAdded: z + .string() + .or(z.date()) + .transform((val) => new Date(val)), description: z.string().max(250), image: z.object({ src: z.string(),