From 26c65f25c7700ad356b0c358296873f0080c2cec Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Wed, 4 Dec 2024 15:17:53 +0000 Subject: [PATCH] apply suggestion --- packages/astro/src/core/config/schema.ts | 14 +++++++++++--- .../test/fixtures/core-image-svg/astro.config.mjs | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/astro/src/core/config/schema.ts b/packages/astro/src/core/config/schema.ts index 529f63f43f980..464ea3de1ace6 100644 --- a/packages/astro/src/core/config/schema.ts +++ b/packages/astro/src/core/config/schema.ts @@ -539,9 +539,11 @@ export const AstroConfigSchema = z.object({ svg: z .union([ z.boolean(), - z.object({ - mode: z.union([z.literal('inline'), z.literal('sprite')]), - }), + z + .object({ + mode: z.union([z.literal('inline'), z.literal('sprite')]).optional(), + }) + .optional(), ]) .optional() .default(ASTRO_CONFIG_DEFAULTS.experimental.svg) @@ -553,6 +555,12 @@ export const AstroConfigSchema = z.object({ mode: 'inline' as SvgRenderMode, } : undefined; + } else { + if (!svgConfig.mode) { + return { + mode: 'inline' as SvgRenderMode, + }; + } } return svgConfig; }), diff --git a/packages/astro/test/fixtures/core-image-svg/astro.config.mjs b/packages/astro/test/fixtures/core-image-svg/astro.config.mjs index 6a04ef793a802..e6b44a9d9e42f 100644 --- a/packages/astro/test/fixtures/core-image-svg/astro.config.mjs +++ b/packages/astro/test/fixtures/core-image-svg/astro.config.mjs @@ -4,6 +4,6 @@ import { defineConfig } from 'astro/config'; export default defineConfig({ integrations: [mdx()], experimental: { - svg: true + svg: {} } });