Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: markdown config typechecking #2970

Merged
merged 19 commits into from
Apr 11, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added comment
  • Loading branch information
JuanM04 committed Apr 10, 2022
commit 9ca82347ffa2c232dc7b5a8c2e461a7880d14dbc
12 changes: 10 additions & 2 deletions packages/markdown/remark/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { BUNDLED_THEMES } from 'shiki';
import { z } from 'zod';

export { Node };
export type PluginFunction<PluginParameters extends any[] = any[], Input = Node, Output = Input> = unified.Plugin<PluginParameters, Input, Output>;
export type PluginFunction<
PluginParameters extends any[] = any[],
Input = Node,
Output = Input
> = unified.Plugin<PluginParameters, Input, Output>;

const plugin = z.union([
z.string(),
Expand All @@ -28,9 +32,13 @@ const shikiConfig = z.object({
export type ShikiConfig = z.infer<typeof shikiConfig>;

export const astroMarkdownOptions = z.object({
// NOTE: "mdx" allows us to parse/compile Astro components in markdown.
// TODO: This should probably be updated to something more like "md" | "astro"
mode: z.enum(['md', 'mdx']).default('mdx'),
drafts: z.boolean().default(false),
syntaxHighlight: z.union([z.literal('shiki'), z.literal('prism'), z.literal(false)]).default('shiki'),
syntaxHighlight: z
.union([z.literal('shiki'), z.literal('prism'), z.literal(false)])
.default('shiki'),
shikiConfig: shikiConfig.default({}),
remarkPlugins: plugin.array().default([]),
rehypePlugins: plugin.array().default([]),
Expand Down