Skip to content

Commit 4d2f1e7

Browse files
committed
[layout] distant image optim
1 parent cc357eb commit 4d2f1e7

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

astro.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ export default defineConfig({
1515
defaultLocale: "en",
1616
},
1717
redirects,
18-
image: { layout: "constrained" },
18+
image: { layout: "constrained", domains: ["gephi.wordpress.com", "raw.githubusercontent.com"] },
1919
});

src/components/BlogRSS.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 { identity } from "lodash-es";
34
import Parser from "rss-parser";
45
@@ -22,7 +23,9 @@ const dateFormatter = new Intl.DateTimeFormat("en-EN", { dateStyle: "long" });
2223
{
2324
feed.items.slice(0, 4).map((item) => (
2425
<article class="blog-post">
25-
{item["media:thumbnail"] && <img alt="" src={item["media:thumbnail"]?.$.url} />}
26+
{item["media:thumbnail"] && (
27+
<Image inferSize alt="" src={item["media:thumbnail"]?.$.url} layout="constrained" />
28+
)}
2629
<h4>
2730
<a href={item.link}>{item.title}</a>
2831
</h4>

src/styles/_contents.scss

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@
178178
}
179179
.banner-image img {
180180
width: auto;
181+
object-fit: contain;
182+
height: auto;
181183
}
182184

183185
.feature:nth-child(2n):not(.feature-left) {
@@ -312,8 +314,9 @@ a.no-decoration {
312314
margin: 0;
313315
}
314316
img {
315-
max-width: 100%;
316-
max-height: 50%;
317+
width: 100%;
318+
height: auto;
319+
max-height: 300px;
317320
object-fit: contain;
318321
}
319322
}

0 commit comments

Comments
 (0)