SanYeCao-blog/src/content.config.ts

34 lines
997 B
TypeScript
Raw Normal View History

2026-03-24 18:01:45 +00:00
// Import the glob loader
import { glob } from "astro/loaders";
// Import utilities from `astro:content`
import { defineCollection } from "astro:content";
// Import Zod
import { z } from "astro/zod";
// Define a `loader` and `schema` for each collection
const blog = defineCollection({
loader: glob({ pattern: '**/[^_]*.md', base: "./src/blog" }),
schema: z.object({
title: z.string(),
pubDate: z.date(),
description: z.string(),
author: z.string(),
image: z.object({
url: z.string(),
alt: z.string()
}),
tags: z.array(z.string())
})
});
const friends = defineCollection({
loader: glob({ pattern: '**/[^_]*.md', base: "./src/friends" }),
schema: z.object({
name: z.string(),
description: z.string(),
url: z.string(),
avatar: z.string()
})
});
2026-03-24 18:01:45 +00:00
// Export a single `collections` object to register your collection(s)
export const collections = { blog, friends };