Create a cats document schema

This commit is contained in:
Maciej Pędzich 2023-09-02 20:50:48 +02:00
parent 8b2a7f0e4d
commit 8592ebc8f2
4 changed files with 33 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -0,0 +1,12 @@
{
"name": "Placeholder",
"description": "This is a placeholder cat with a photo taken from placekitten.com",
"image": {
"src": "/images/maciejpedzich-placeholder.jpg",
"alt": "Sample alt text"
},
"owner": {
"name": "Maciej Pędzich",
"link": "https://maciejpedzi.ch"
}
}

20
src/content/config.ts Normal file
View File

@ -0,0 +1,20 @@
import { z, defineCollection } from 'astro:content';
const cats = defineCollection({
type: 'data',
schema: z.object({
name: z.string(),
description: z.string().max(250),
image: z.object({
src: z.string(),
alt: z.string()
}),
passedAway: z.boolean().optional().default(false),
owner: z.object({
name: z.string(),
link: z.string().optional()
})
})
});
export const collections = { cats };

1
src/env.d.ts vendored
View File

@ -1 +1,2 @@
/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" /> /// <reference types="astro/client" />