Optimize images consumption
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
import Picture from "~/components/core/Picture.astro";
|
import { Image } from "@astrojs/image/components";
|
||||||
|
|
||||||
import { findPostsByIds } from "~/utils/posts";
|
import { findPostsByIds } from "~/utils/posts";
|
||||||
import { findImage } from "~/utils/images";
|
import { findImage } from "~/utils/images";
|
||||||
@ -36,12 +36,11 @@ const items = await Promise.all(
|
|||||||
{
|
{
|
||||||
items.map((post) => (
|
items.map((post) => (
|
||||||
<article class="mb-6 transition">
|
<article class="mb-6 transition">
|
||||||
<Picture
|
<Image
|
||||||
src={post.image}
|
src={post.image}
|
||||||
class="object-cover w-full h-64 mb-6 rounded shadow-lg bg-gray-400 dark:bg-slate-700"
|
class="object-cover w-full h-64 mb-6 rounded shadow-lg bg-gray-400 dark:bg-slate-700"
|
||||||
widths={[400]}
|
width={400}
|
||||||
alt="Post 2 Image"
|
alt={post.title}
|
||||||
aspectRatio="16:9"
|
|
||||||
/>
|
/>
|
||||||
<h3 class="mb-2 text-xl font-bold leading-snug sm:text-2xl font-heading">
|
<h3 class="mb-2 text-xl font-bold leading-snug sm:text-2xl font-heading">
|
||||||
<a
|
<a
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
import Picture from "~/components/core/Picture.astro";
|
import { Image } from "@astrojs/image/components";
|
||||||
import PostTags from "~/components/atoms/Tags.astro";
|
import PostTags from "~/components/atoms/Tags.astro";
|
||||||
|
|
||||||
import { getPermalink } from "~/utils/permalinks";
|
import { getPermalink } from "~/utils/permalinks";
|
||||||
@ -16,13 +16,11 @@ const image = await findImage(post.image);
|
|||||||
<div
|
<div
|
||||||
class="relative h-0 pb-[56.25%] md:pb-[75%] md:h-80 lg:pb-[56.25%] overflow-hidden bg-gray-400 dark:bg-slate-700 rounded shadow-lg"
|
class="relative h-0 pb-[56.25%] md:pb-[75%] md:h-80 lg:pb-[56.25%] overflow-hidden bg-gray-400 dark:bg-slate-700 rounded shadow-lg"
|
||||||
>
|
>
|
||||||
<Picture
|
<Image
|
||||||
src={image}
|
src={image}
|
||||||
class="absolute inset-0 w-full h-full object-cover mb-6 rounded shadow-lg"
|
class="absolute inset-0 object-cover w-full h-full mb-6 rounded shadow-lg bg-gray-400 dark:bg-slate-700"
|
||||||
widths={[400, 768]}
|
width={400}
|
||||||
sizes="(max-width: 767px) 400px, 768px"
|
alt={post.title}
|
||||||
alt={post.description}
|
|
||||||
aspectRatio={1}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
@ -32,7 +32,7 @@ const { post } = Astro.props;
|
|||||||
}
|
}
|
||||||
</header>
|
</header>
|
||||||
<div
|
<div
|
||||||
class="container mx-auto px-8 sm:px-6 max-w-3xl prose prose-lg lg:prose-xl dark:prose-invert dark:prose-headings:text-slate-300 prose-md prose-headings:font-heading prose-headings:leading-tighter prose-headings:tracking-tighter prose-headings:font-bold prose-a:text-primary-600 dark:prose-a:text-primary-400 prose-img:rounded-md prose-img:shadow-lg mt-8"
|
class="container mx-auto px-6 sm:px-6 max-w-3xl prose prose-lg lg:prose-xl dark:prose-invert dark:prose-headings:text-slate-300 prose-md prose-headings:font-heading prose-headings:leading-tighter prose-headings:tracking-tighter prose-headings:font-bold prose-a:text-primary-600 dark:prose-a:text-primary-400 prose-img:rounded-md prose-img:shadow-lg mt-8"
|
||||||
>
|
>
|
||||||
<Fragment set:html={post.body} />
|
<Fragment set:html={post.body} />
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user