I have a directory of markdown files for my blog posts. I created a src/content.config.ts withtje following content:
import { defineCollection, z } from "astro:content";
import { glob } from "astro/loaders";
const blogs = defineCollection({
loader: glob({ pattern: "*.md", base: "./content/blog" }),
schema: z.object({
title: z.string(),
description: z.string(),
}),
});
export const collections = { blogs };
I am retrieving the collection via:
import { getCollection } from "astro:content";
interface Frontmatter {
title: string;
description: string;
}
const posts = await getCollection("blogs");
I'm gettting the error:
The collection "blogs" does not exist or is empty. Please check your content config file for errors.
I'm not sure what went wrong according to documentation I'm referencing.