31 lines
942 B
TypeScript
31 lines
942 B
TypeScript
import { defineCollection, z } from "astro:content";
|
|
import { glob } from 'astro/loaders';
|
|
import { loadEnv } from "vite";
|
|
|
|
const { CONTENT_BASE } = loadEnv(process.env.NODE_ENV ?? "", process.cwd(), "");
|
|
const contentBase = CONTENT_BASE || "./src/content";
|
|
|
|
const blog = defineCollection({
|
|
loader: glob({ pattern: '**/*.{md,mdx}', base: `${contentBase}/blog` }),
|
|
schema: z.object({
|
|
title: z.string(),
|
|
description: z.string().nullish(),
|
|
date: z.coerce.date(),
|
|
draft: z.boolean().optional(),
|
|
tags: z.array(z.string()).optional(),
|
|
}),
|
|
});
|
|
|
|
const projects = defineCollection({
|
|
loader: glob({ pattern: '**/*.{md,mdx}', base: `${contentBase}/projects` }),
|
|
schema: z.object({
|
|
title: z.string(),
|
|
description: z.string(),
|
|
date: z.coerce.date(),
|
|
draft: z.boolean().optional(),
|
|
demoURL: z.string().nullish(),
|
|
repoURL: z.string().nullish(),
|
|
}),
|
|
});
|
|
|
|
export const collections = { blog, projects };
|