30 lines
No EOL
656 B
TypeScript
30 lines
No EOL
656 B
TypeScript
import { defineCollection } from 'astro:content';
|
|
import { glob } from 'astro/loaders';
|
|
import { z } from 'astro/zod';
|
|
|
|
|
|
const postSchema = z.object({
|
|
title: z.string(),
|
|
subtitle: z.string(),
|
|
description: z.string(),
|
|
image: z.object({
|
|
path: z.string(),
|
|
alt: z.string()
|
|
}),
|
|
author: z.string(),
|
|
date: z.coerce.date(),
|
|
slug: z.string(),
|
|
time2read: z.int()
|
|
});
|
|
|
|
export type PostData = z.infer<typeof postSchema>;
|
|
|
|
const posts = defineCollection({
|
|
loader: glob({
|
|
pattern: "**/*.{md,mdx}",
|
|
base: "./src/pages/blog/",
|
|
}),
|
|
schema: postSchema
|
|
});
|
|
|
|
export const collections = { posts }; |