From 5572e8d9b33eb1e9168d221f22348d3b3cb4b29a Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Thu, 21 Jul 2022 11:04:37 -0400 Subject: [PATCH] refactor: add legacy.jsxInMarkdown flag to config --- packages/astro/src/@types/astro.ts | 10 ++++++++++ packages/astro/src/core/config.ts | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index f4bb441c3c..317e03f179 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -704,6 +704,16 @@ export interface AstroUserConfig { buildOptions?: never; /** @deprecated `devOptions` has been renamed to `server` */ devOptions?: never; + + legacy?: { + /** + * Enable components and JSX expressions in markdown + * Consider our MDX integration before applying this flag! + * @see https://docs.astro.build/en/guides/integrations-guide/mdx/ + * Default: false + */ + jsxInMarkdown?: boolean; + }; } // NOTE(fks): We choose to keep our hand-generated AstroUserConfig interface so that diff --git a/packages/astro/src/core/config.ts b/packages/astro/src/core/config.ts index b474b29dfa..17f5483b94 100644 --- a/packages/astro/src/core/config.ts +++ b/packages/astro/src/core/config.ts @@ -50,6 +50,9 @@ const ASTRO_CONFIG_DEFAULTS: AstroUserConfig & any = { rehypePlugins: [], }, vite: {}, + legacy: { + jsxInMarkdown: false, + } }; async function resolvePostcssConfig(inlineOptions: any, root: URL): Promise { @@ -216,6 +219,12 @@ export const AstroConfigSchema = z.object({ vite: z .custom((data) => data instanceof Object && !Array.isArray(data)) .default(ASTRO_CONFIG_DEFAULTS.vite), + legacy: z + .object({ + markdownJsx: z.boolean().optional().default(ASTRO_CONFIG_DEFAULTS.legacy.jsxInMarkdown), + }) + .optional() + .default({}), }); /** Turn raw config values into normalized values */