refactor(NavHeader.astro): Optimise the header background image size and resolution

Moved to using Astro's `getImage()` function to serve the image as an avif image wich was been scaled down so it's isn't larger resolution than it need to be
This commit is contained in:
BuyMyMojo 2024-12-20 15:05:50 +11:00
parent 9c8e5523c3
commit 8f5c40bed5
3 changed files with 9 additions and 4 deletions

View file

@ -1,12 +1,16 @@
---
import { Picture } from "astro:assets";
import { Picture, getImage } from "astro:assets";
import pfp from "../img/sites/avatar.png";
import Partition from "./Partition.astro";
import myBackground from "../img/sites/avatar-ht-f.png"
const optimizedBackground = await getImage({src: myBackground, format: 'avif', quality: 40, width: 680})
---
<div
class="rounded-2xl flex flex-col shadow-xl shadow-black py-8 mb-8 items-center backdrop-blur-3xl bg-center bg-[url('/static/img/sites/avatar-ht-f.webp')]"
style="width: 670px; border: 1px solid var(--border);"
style={`width: 670px; border: 1px solid var(--border); background-image: url('${optimizedBackground.src}');`}
class="rounded-2xl flex flex-col shadow-xl shadow-black py-8 mb-8 items-center bg-center bg-cover"
>
<Picture
src={pfp}

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 KiB