> Astro Content Collections

Manage content in Astro with type-safe collections, MDX, and static generation.

fetch
$curl "https://skillshub.wtf/skillshub-team/catalog-batch5/astro-content?format=md"
SKILL.mdAstro Content Collections

Astro Content Collections

Define Collection

// src/content/config.ts
import { defineCollection, z } from 'astro:content';
const blog = defineCollection({
    type: 'content',
    schema: z.object({ title: z.string(), date: z.date(), tags: z.array(z.string()).optional() }),
});
export const collections = { blog };

Content Files

---
title: My First Post
date: 2024-01-15
tags: [typescript, astro]
---
# Hello World
Content here...

Query

---
import { getCollection } from 'astro:content';
const posts = await getCollection('blog');
const sorted = posts.sort((a, b) => b.data.date - a.data.date);
---
{sorted.map(post => <a href={`/blog/${post.slug}`}>{post.data.title}</a>)}

┌ stats

installs/wk0
░░░░░░░░░░
first seenMar 18, 2026
└────────────

┌ tags

└────────────