diff --git a/packages/starlight/components/Hero.astro b/packages/starlight/components/Hero.astro index 51be009ab46..d18dd4d9d5e 100644 --- a/packages/starlight/components/Hero.astro +++ b/packages/starlight/components/Hero.astro @@ -28,11 +28,13 @@ if (image) { rawHtml = image.html; } } +const isDarkSvg = darkImage?.format === 'svg'; +const isLightSvg = lightImage?.format === 'svg'; ---
{ - darkImage && ( + darkImage && !isDarkSvg && ( ) } - {lightImage && } + { + darkImage && isDarkSvg && ( + {imageAttrs.alt} + ) + } + {lightImage && !isLightSvg && } + { + lightImage && isLightSvg && ( + {imageAttrs.alt} + ) + } + {rawHtml &&
}
diff --git a/packages/starlight/components/SiteTitle.astro b/packages/starlight/components/SiteTitle.astro index 2f4b829943e..14cf87c2d34 100644 --- a/packages/starlight/components/SiteTitle.astro +++ b/packages/starlight/components/SiteTitle.astro @@ -2,6 +2,7 @@ import { logos } from 'virtual:starlight/user-images'; import config from 'virtual:starlight/user-config'; import type { Props } from '../props'; +import { Image } from 'astro:assets'; const { siteTitle, siteTitleHref } = Astro.props; --- @@ -9,22 +10,45 @@ const { siteTitle, siteTitleHref } = Astro.props; { config.logo && logos.dark && ( <> - {config.logo.alt} - {/* Show light alternate if a user configure both light and dark logos. */} - {!('src' in config.logo) && ( + {logos.dark.format === 'svg' ? ( {config.logo.alt} + ) : ( + {config.logo.alt} + )} + {!('src' in config.logo) && logos.light && ( + <> + {logos.light.format === 'svg' ? ( + {config.logo.alt} + ) : ( + {config.logo.alt} + )} + )} )