Files
warmbly/site/src/content.config.ts
T
Matthew Meszaros db832fa896 feat: add blog content collection on the Astro 5 content layer
Posts are markdown/MDX files under src/content/blog with a zod-validated
schema (title, description, pubDate, tags, optional cover, draft). All
listing surfaces read through getPublishedPosts() so draft filtering has
a single owner. @astrojs/mdx is pinned to ^4.x: the npm latest (v6)
requires Astro 6 and would break this tree.
2026-06-10 17:14:57 +02:00

25 lines
961 B
TypeScript

import { defineCollection, z } from 'astro:content';
import { glob } from 'astro/loaders';
// Blog posts: markdown/MDX files under src/content/blog.
// The file name (without extension) becomes the URL slug, e.g.
// src/content/blog/quarantine-early.mdx -> /blog/quarantine-early/
const blog = defineCollection({
loader: glob({ pattern: '**/*.{md,mdx}', base: './src/content/blog' }),
schema: z.object({
title: z.string(),
description: z.string(),
pubDate: z.coerce.date(),
updatedDate: z.coerce.date().optional(),
author: z.string().default('Warmbly team'),
// Short topic labels rendered as chips; not pages. Keep them few and reused.
tags: z.array(z.string()).default([]),
// Optional card/header image (path under /public, e.g. "/blog/foo.webp").
// Posts without one get a generated sky cover.
cover: z.string().optional(),
draft: z.boolean().default(false),
}),
});
export const collections = { blog };