A blog isn't worth much if you don't have a place to put your content. In this lesson we'll dive deep into Astros content collections API which is a feature for organizing all of your content and ensuring when you create your content you add the proper data to your front matter.
To do this we'll create a content folder that contains a config.ts
inside that config we'll use defineCollection
from astro:content
to declare what our blog data will look like. From here you can set a schema
property and use zod to declare the shape of the data you'd like your content to be in.
When actually creating content, Astro will throw errors if you miss an attribute in your frontmatter that was set in your schema.
Astro also gives you an easy way to grab all the content you have with the getCollection
function. We'll use this function to add links to our latests blog posts on the home page.