Skip to content

Commit b907d40

Browse files
Merge pull request #2 from geo-engine/bring-down-10mb-bg-image
no more 10 mb beach image
2 parents 0389b13 + f2c37ea commit b907d40

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/components/Hero.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
import {useTranslations} from '../i18n/utils';
33
import geoEngineTitle from '../images/Strand.png';
4+
import {optimizedBackgroundImage} from '../images/util';
45
56
const t = useTranslations(Astro.currentLocale);
67
7-
const geoEngineBackground = 'url(' + geoEngineTitle.src + ')';
8+
const geoEngineBackground = await optimizedBackgroundImage(geoEngineTitle);
89
---
910

1011
<style define:vars={{geoEngineBackground}}>

src/components/Section.astro

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
import {getImage} from 'astro:assets';
32
import beachBg from '../images/Strand.png';
43
import blueBg from '../images/backgrounds/GeoEngine_Structure_midblue.svg';
54
import greenBg from '../images/backgrounds/GeoEngine_Structure_lightgreen.svg';
65
import lightblueBg from '../images/backgrounds/GeoEngine_Structure_lightblue.svg';
6+
import {optimizedBackgroundImage} from '../images/util';
77
88
interface Props {
99
bg?: 'green' | 'blue' | 'lightblue' | 'beach';
@@ -12,11 +12,6 @@ interface Props {
1212
1313
const {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-
2015
let backgroundImage = 'none';
2116
if (bg == 'green') {
2217
backgroundImage = await optimizedBackgroundImage(greenBg);

src/images/util.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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+
}

0 commit comments

Comments
 (0)