import { defineCollection, z } from 'astro:content'; import { glob } from 'astro/loaders'; import type { Loader } from 'astro/loaders'; import matter from 'gray-matter'; import { glob as tinyglob } from 'tinyglobby'; import { readFile } from 'node:fs/promises'; const POSTS_BASE = 'src/posts'; // Shared front-matter schema for every post, regardless of authoring format. const schema = z.object({ title: z.string(), image: z.string().optional(), excerpt: z.string().optional(), layout: z.string().optional(), }); // Markdown / MDX posts use Astro's built-in pipeline (remark/rehype, MDX + React). const posts = defineCollection({ loader: glob({ pattern: '**/*.{md,markdown,mdx}', base: `./${POSTS_BASE}` }), schema, }); // Raw-HTML posts: Astro's glob loader doesn't render `.html` bodies, and some of // these embed a large inline