File tree Expand file tree Collapse file tree 3 files changed +9
-7
lines changed
Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 11---
22import {useTranslations } from ' ../i18n/utils' ;
33import geoEngineTitle from ' ../images/Strand.png' ;
4+ import {optimizedBackgroundImage } from ' ../images/util' ;
45
56const t = useTranslations (Astro .currentLocale );
67
7- const geoEngineBackground = ' url( ' + geoEngineTitle . src + ' ) ' ;
8+ const geoEngineBackground = await optimizedBackgroundImage ( geoEngineTitle ) ;
89---
910
1011<style define:vars ={ {geoEngineBackground }} >
Original file line number Diff line number Diff line change 11---
2- import {getImage } from ' astro:assets' ;
32import beachBg from ' ../images/Strand.png' ;
43import blueBg from ' ../images/backgrounds/GeoEngine_Structure_midblue.svg' ;
54import greenBg from ' ../images/backgrounds/GeoEngine_Structure_lightgreen.svg' ;
65import lightblueBg from ' ../images/backgrounds/GeoEngine_Structure_lightblue.svg' ;
6+ import {optimizedBackgroundImage } from ' ../images/util' ;
77
88interface Props {
99 bg? : ' green' | ' blue' | ' lightblue' | ' beach' ;
@@ -12,11 +12,6 @@ interface Props {
1212
1313const {bg, box = false } = Astro .props ;
1414
15- async function optimizedBackgroundImage(src : ImageMetadata ): Promise <string > {
16- const bg = await getImage ({src });
17- return ` url('${bg .src }') ` ;
18- }
19-
2015let backgroundImage = ' none' ;
2116if (bg == ' green' ) {
2217 backgroundImage = await optimizedBackgroundImage (greenBg );
Original file line number Diff line number Diff line change 1+ import { getImage } from 'astro:assets' ;
2+
3+ export async function optimizedBackgroundImage ( src : ImageMetadata ) : Promise < string > {
4+ const bg = await getImage ( { src} ) ;
5+ return `url('${ bg . src } ')` ;
6+ }
You can’t perform that action at this time.
0 commit comments