Introduce a dateAdded field in content config

This commit is contained in:
Maciej Pędzich 2023-09-03 03:58:03 +02:00
parent d36de6ccbd
commit 9449d528f2
2 changed files with 5 additions and 0 deletions

View File

@ -1,5 +1,6 @@
{ {
"name": "Placeholder", "name": "Placeholder",
"dateAdded": "2023-09-02T18:50:00.066Z",
"description": "This is a placeholder cat with a photo taken from placekitten.com", "description": "This is a placeholder cat with a photo taken from placekitten.com",
"image": { "image": {
"src": "/images/maciejpedzich-placeholder.jpg", "src": "/images/maciejpedzich-placeholder.jpg",

View File

@ -4,6 +4,10 @@ const cats = defineCollection({
type: 'data', type: 'data',
schema: z.object({ schema: z.object({
name: z.string(), name: z.string(),
dateAdded: z
.string()
.or(z.date())
.transform((val) => new Date(val)),
description: z.string().max(250), description: z.string().max(250),
image: z.object({ image: z.object({
src: z.string(), src: z.string(),