Astro Content Collections
// src/content/config.ts
import { defineCollection, z } from "astro:content";
const blog = defineCollection({
schema: z.object({
title: z.string(),
date: z.date(),
tags: z.array(z.string()),
draft: z.boolean().default(false),
}),
});
export const collections = { blog };사용
---
import { getCollection } from "astro:content";
const posts = await getCollection("blog", ({ data }) => !data.draft);
---
{posts.map(post => <PostCard post={post} />)}마크다운 파일이 타입 안전한 데이터 소스가 됩니다.
댓글 0