Files
blazestar.net/src/content.config.ts
2026-04-21 15:39:16 -07:00

45 lines
1.2 KiB
TypeScript

import {
ObsidianDocumentSchema,
ObsidianMdLoader,
} from "astro-loader-obsidian";
import { glob } from "astro/loaders";
import { defineCollection, z } from "astro:content";
const blog = defineCollection({
// Load Markdown and MDX files in the `src/content/blog/` directory.
loader: glob({ base: "./src/content/blog", pattern: "**/*.{md,mdx}" }),
// Type-check frontmatter using a schema
schema: ({ image }) =>
z.object({
title: z.string(),
description: z.string(),
// Transform string to Date object
// Presence of this value indicates that the post is published
pubDate: z.coerce.date().optional(),
updatedDate: z.coerce.date().optional(),
heroImage: image().optional(),
tags: z.array(z.string()).optional(),
}),
});
const page = defineCollection({
loader: glob({ base: "./src/content/page", pattern: "**/*.{md,mdx}" }),
schema: ({ image }) =>
z.object({
title: z.string(),
}),
});
const notes = defineCollection({
loader: ObsidianMdLoader({
base: "src/content/notes",
url: "notes",
}),
schema: ({ image }) =>
ObsidianDocumentSchema.extend({
image: image().optional(),
}),
});
export const collections = { blog, page, notes };