--- import * as fs from 'fs' import webpPath from '../images/background.webp' import avifPath from '../images/background.avif' import noBackground from '../images/no-background.webp' interface Props { image?: boolean } const { image } = Astro.props let imageLoaded = false const checkBackground = () => { if (!fs.existsSync(avifPath.src) && !fs.existsSync(webpPath.src)) { imageLoaded = true } else { imageLoaded = false } } checkBackground() --- { image && (imageLoaded ? ( An image background ) : ( An alternative background if found no image background )) }