Skip to main content
InterviewHubPRO
Section Overview
Q13

Question 13 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

26%
Astro Islands & SSR (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

What are Astro Content Collections (`src/content/`)?

senior LevelCode ExampleSystem DesignAstro

In Simple Words: Astro provides a structured, type-safe content engine inside src/content/:

typescript
// src/content/config.ts
import { defineCollection, z } from 'astro:content';

const blog = defineCollection({
  type: 'content',
  schema: z.object({
    title: z.string(),
    publishDate: z.date(),
    author: z.string().default('Anonymous'),
    tags: z.array(z.string()),
    draft: z.boolean().default(false)
  })
});

export const collections = { blog };
  • If a markdown file has a missing publishDate or invalid YAML format, the Astro compiler throws a build error with line numbers!
  • Queries are fully typed: const posts = await getCollection('blog');.