Files
svgl/content-collections.ts
T
2025-08-29 00:13:41 +01:00

34 lines
850 B
TypeScript

import { z } from "zod";
// Content Collections:
import { compileMarkdown } from "@content-collections/markdown";
import { defineCollection, defineConfig } from "@content-collections/core";
// Shiki:
import rehypeShiki from "@shikijs/rehype/core";
import { shikiHighlighter, rehypeShikiOptions } from "./src/utils/shiki";
const docs = defineCollection({
name: "docs",
directory: "src/docs",
include: "**/*.md",
schema: z.object({
title: z.string(),
description: z.string(),
}),
transform: async (document, context) => {
const highlighter = await shikiHighlighter();
const html = await compileMarkdown(context, document, {
rehypePlugins: [[rehypeShiki, highlighter, rehypeShikiOptions]],
});
return {
...document,
html,
};
},
});
export default defineConfig({
collections: [docs],
});