From 9344a2538aa4e82318a0015ed42e8bda8b07a909 Mon Sep 17 00:00:00 2001 From: Michael Stramel Date: Wed, 6 Nov 2024 01:32:01 -0600 Subject: [PATCH] refactor: swap experimental.svg schema implementation --- packages/astro/src/core/config/schema.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/core/config/schema.ts b/packages/astro/src/core/config/schema.ts index c239047334e9..c19b4d9559f4 100644 --- a/packages/astro/src/core/config/schema.ts +++ b/packages/astro/src/core/config/schema.ts @@ -528,14 +528,24 @@ export const AstroConfigSchema = z.object({ .boolean() .optional() .default(ASTRO_CONFIG_DEFAULTS.experimental.contentIntellisense), - svg: z + svg: z.union([ + z.boolean(), + z .object({ mode: z .union([z.literal('inline'), z.literal('sprite')]) .optional() .default(ASTRO_CONFIG_DEFAULTS.experimental.svg.mode), }) - .optional(), + ]) + .optional() + .transform((svgConfig) => { + // Handle normalization of `experimental.svg` config boolean values + if (typeof svgConfig === 'boolean') { + return svgConfig ? ASTRO_CONFIG_DEFAULTS.experimental.svg : undefined; + } + return svgConfig; + }), }) .strict( `Invalid or outdated experimental feature.\nCheck for incorrect spelling or outdated Astro version.\nSee https://docs.astro.build/en/reference/configuration-reference/#experimental-flags for a list of all current experiments.`,