Collections
A general overview of how Astro’s content collections are used.
Types of content collections
pages
: Used for generating pages and/or cards.presets
: Default values that can be referenced by pagesimages
: Adds type-safety and optimization for local images
Setup collections
Create a content collections config file at src/content/config.ts
, and add the following content:
// src/content/config.ts
import { defineCollection } from 'astro:content'
import imageLoader from 'fulldev-ui/loaders/imageLoader.ts'
import imageSchema from 'fulldev-ui/schemas/imageSchema.ts'
import pageSchema from 'fulldev-ui/schemas/pageSchema.ts'
import presetSchema from 'fulldev-ui/schemas/presetSchema.ts'
export const collections = {
pages: defineCollection({
type: 'content',
schema: pageSchema,
}),
presets: defineCollection({
type: 'data',
schema: presetSchema,
}),
images: defineCollection({
loader: imageLoader,
schema: imageSchema,
}),
}