fix: cover as public-path string (Sveltia uploads) + render cover in article

This commit is contained in:
ctao
2026-07-24 20:34:22 +02:00
parent ed45ff6d54
commit 228ad5b60b
3 changed files with 13 additions and 10 deletions
+11 -10
View File
@@ -6,16 +6,17 @@ import { glob } from 'astro/loaders';
// renders them to static HTML at build time.
const news = defineCollection({
loader: glob({ pattern: '**/*.md', base: './src/content/news' }),
schema: ({ image }) =>
z.object({
title: z.string(),
description: z.string(),
date: z.coerce.date(),
category: z.string().default('news'),
author: z.string().default('CTAO'),
cover: image().optional(),
draft: z.boolean().default(false),
}),
schema: z.object({
title: z.string(),
description: z.string(),
date: z.coerce.date(),
category: z.string().default('news'),
author: z.string().default('CTAO'),
// Public-path string, e.g. "/uploads/foo.jpg" — Sveltia uploads media to
// public/uploads, which Astro's image() helper can't validate (src/ only).
cover: z.string().optional(),
draft: z.boolean().default(false),
}),
});
export const collections = { news };