feat: implement automatic image optimization with Astro Assets
- Configure content collections to use image() helper for type-safe image references - Replace all <img> tags with <Image> component from astro:assets - Migrate images from /public to /src/assets for automatic optimization - Update blog posts to use relative paths in frontmatter (../../assets/photos/) - Remove unused images and duplicates from /public folder - Update Footer component to use optimized SVG icons - Clean up manifest.json to use favicon.ico instead of deleted photos Performance improvements: - remote.jpg: 1.8MB → 128KB (93% reduction) - me.png: 71KB → 12KB (83% reduction) - Automatic WebP conversion - Tree-shaking: only used images are optimized /public folder reduced from 2.3MB to 32KB (only essential files) Build output: 2.2MB with fully optimized images ready for S3 deployment
This commit is contained in:
parent
da03ed9e6f
commit
289dc9ef00
47 changed files with 632 additions and 419 deletions
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
import type { CollectionEntry } from "astro:content";
|
||||
import { getCollection } from "astro:content";
|
||||
import { Image } from "astro:assets";
|
||||
import Footer from "../components/Footer.astro";
|
||||
import Navbar from "../components/Navbar.astro";
|
||||
import BaseLayout from "../layouts/BaseLayout.astro";
|
||||
|
|
@ -33,7 +34,6 @@ const initialPosts: BlogPost[] = sortedPosts.slice(0, 6);
|
|||
<BaseLayout
|
||||
title="Lorenzo Iovino >> Blog"
|
||||
description="Blog posts and articles by Lorenzo Iovino"
|
||||
canonicalUrl="https://www.lorenzoiovino.com/blog"
|
||||
>
|
||||
<Navbar />
|
||||
<div class="min-h-screen pt-16 bg-secondary">
|
||||
|
|
@ -115,10 +115,14 @@ const initialPosts: BlogPost[] = sortedPosts.slice(0, 6);
|
|||
{post.data.heroImage && (
|
||||
<a href={`/blog/${post.slug}`} class="block">
|
||||
<div class="relative h-64 overflow-hidden">
|
||||
<img
|
||||
<Image
|
||||
src={post.data.heroImage}
|
||||
alt={post.data.title}
|
||||
class="w-full h-full object-cover hover:scale-105 transition-transform duration-300"
|
||||
width={1200}
|
||||
height={630}
|
||||
quality={80}
|
||||
format="webp"
|
||||
/>
|
||||
<div class="absolute inset-0 bg-gradient-to-t from-black/50 to-transparent" />
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue