Skip to content

Commit cbdd356

Browse files
committed
Optmize images
1 parent 3e31094 commit cbdd356

File tree

8 files changed

+178
-174
lines changed

8 files changed

+178
-174
lines changed

astro.config.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import manifest from "./webmanifest.json";
77
// https://astro.build/config
88
export default defineConfig({
99
site: "https://linwood.dev",
10+
image: {
11+
responsiveStyles: true,
12+
layout: "constrained",
13+
domains: ["avatars1.githubusercontent.com"],
14+
},
1015
integrations: [
1116
mdx(),
1217
sitemap(),
@@ -19,7 +24,7 @@ export default defineConfig({
1924
globPatterns: [
2025
"**/*.{html,js,css,png,svg,json,ttf,pf_fragment,pf_index,pf_meta,pagefind,wasm}",
2126
],
22-
maximumFileSizeToCacheInBytes: 3000000
27+
maximumFileSizeToCacheInBytes: 3000000,
2328
},
2429
experimental: {
2530
directoryAndTrailingSlashHandler: true,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@astrojs/sitemap": "^3.4.1",
1616
"@linwooddev/style": "^0.4.2",
1717
"@phosphor-icons/web": "^2.1.2",
18-
"astro": "^5.9.4",
18+
"astro": "^5.10.0",
1919
"sharp": "^0.34.2",
2020
"typescript": "^5.8.3"
2121
},

pnpm-lock.yaml

Lines changed: 155 additions & 160 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Author.astro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
import { getProject } from "src/blog";
3-
import Link from "./Link.astro";
4-
import { getCollection, getEntry } from "astro:content";
2+
import { getEntry } from "astro:content";
3+
import { Image } from 'astro:assets';
4+
55
export interface Props {
66
author?: string;
77
}
@@ -13,7 +13,7 @@ const current = author && await getEntry("authors", author);
1313
{
1414
current && (
1515
<a href={current.data.url} class="author">
16-
<img class="author-avatar" src={current.data.avatar} />
16+
<Image class="author-avatar" alt={`Avatar of ${current.data.name}`} src={current.data.avatar} width={64} height={64} />
1717
<p class="author-name">{current.data.name}</p>
1818
</a>
1919
)

src/components/Header.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
---
2+
import { Image } from "astro:assets";
23
import Link from "./Link.astro";
34
import { SITE_TITLE } from "../consts";
5+
import logo from "../../public/logos/logo.png";
46
---
57

68
<header class="navbar">
79
<a href="/" class="navbar-title">
8-
<img src="/logos/logo.png" height="32" width="32" alt="Astro Logo" />
10+
<Image src={logo} height="32" width="32" alt="Linwood Logo" />
911
{SITE_TITLE}
1012
</a>
1113
<nav class="navbar-items">

src/components/ProjectHero.astro

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
import { Image } from "astro:assets";
23
import { getProject } from "src/blog";
34
import Link from "./Link.astro";
45
export interface Props {
@@ -13,9 +14,11 @@ const current = project && await getProject(project);
1314
current && (
1415
<section>
1516
<div class="row gap-md pv-sm align-center justify-stretch">
16-
<img
17+
<Image
1718
class="thumbnail-image"
1819
src={`/logos/${current.data.logo ?? current.id}.svg`}
20+
height={100}
21+
width={100}
1922
alt={current.data.title}
2023
/>
2124
<div class="col gap-md">

src/layouts/BlogPost.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
import { Image } from "astro:assets";
23
import type { CollectionEntry } from "astro:content";
34
import FormattedDate from "@components/FormattedDate.astro";
45
import Link from "@components/Link.astro";
@@ -62,7 +63,7 @@ const platforms = [
6263
</div>
6364
</dialog>
6465
<article class="col">
65-
{heroImage && <img width={720} height={360} src={heroImage} alt="" />}
66+
{heroImage && <Image fit="" width={720} height={360} src={heroImage} alt="" />}
6667
<h1>{title}</h1>
6768
<FormattedDate date={date} />
6869
<ProjectHero project={project} />

src/pages/index.astro

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
---
2-
import BaseHead from "@components/BaseHead.astro";
3-
import Header from "@components/Header.astro";
4-
import Footer from "@components/Footer.astro";
2+
import { Image } from "astro:assets";
53
import { SITE_TITLE, SITE_DESCRIPTION } from "../consts";
64
import { getProjects } from "../blog";
75
import DefaultLayout from "../layouts/DefaultLayout.astro";
@@ -31,7 +29,7 @@ const libraries = await getCollection("libraries");
3129
class="col align-center justify-between h-full"
3230
style={{ width: "150px" }}
3331
>
34-
<img
32+
<Image
3533
src={`/logos/${e.data.logo ?? e.id}.svg`}
3634
alt={e.data.title}
3735
width="100"
@@ -50,7 +48,7 @@ const libraries = await getCollection("libraries");
5048
<Table>
5149
{
5250
libraries.map((e) => (
53-
<TableItem>
51+
<TableItem href={e.data.url}>
5452
<p class="text-center mb-none">{e.data.id}</p>
5553
<p class="normal text-center mt-none">{e.data.description}</p>
5654
</TableItem>

0 commit comments

Comments
 (0)