@studiocms/md
Version:
Add Markdown Support to your StudioCMS project with ease!
47 lines (46 loc) • 1.92 kB
JavaScript
import { z } from "astro/zod";
import { StudioCMSSanitizeOptionsSchema } from "studiocms/schemas";
const AstroMarkdownSchema = z.object({
/**
* Specifies the Markdown flavor, fixed to 'astro'.
* This property is used to differentiate between different Markdown configurations.
*/
flavor: z.literal("astro"),
/**
* Schema for options used to sanitize Markdown content in StudioCMS.
*
* @remarks
* This schema defines the configuration for controlling which elements and attributes
* are allowed, blocked, or dropped during the sanitization process. It also provides
* options for handling components, custom elements, and comments.
*/
sanitize: StudioCMSSanitizeOptionsSchema
});
const StudioCMSMarkdownSchema = AstroMarkdownSchema.extend({
/**
* Specifies the markdown flavor, fixed to 'studiocms'.
* This property is used to differentiate between different Markdown configurations.
*/
flavor: z.literal("studiocms"),
/**
* Optional callouts style, defaults to 'obsidian'.
* This property allows users to choose a specific callout theme for Markdown content.
*/
callouts: z.union([z.literal("github"), z.literal("obsidian"), z.literal("vitepress"), z.literal(false)]).optional().default("obsidian"),
/**
* Optionally enables automatic linking of headings, defaults to true.
* This property allows users to automatically create links for headings in Markdown content.
*/
autoLinkHeadings: z.boolean().optional().default(true),
/**
* Optionally enables Discord subtext, defaults to true.
* This property allows users to include Discord-style subtext in Markdown content.
*/
discordSubtext: z.boolean().optional().default(true)
});
const MarkdownSchema = z.union([AstroMarkdownSchema, StudioCMSMarkdownSchema]).optional().default({ flavor: "studiocms" });
export {
AstroMarkdownSchema,
MarkdownSchema,
StudioCMSMarkdownSchema
};