Fix image size in Blogs
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
import { getAllPaginatedBlogs } from '@/content/blogs/blogs';
|
import { getAllPaginatedBlogs } from '@/content/blogs/blogs';
|
||||||
import { getSettings } from '@/content/settings/settings';
|
import { getSettings } from '@/content/settings/settings';
|
||||||
import CalendarIcon from '@/icons/CalendarIcon.astro';
|
import CalendarIcon from '@/icons/CalendarIcon.astro';
|
||||||
import { getImageUrl } from '@/lib/images';
|
import { getImageSize, getImageUrl } from '@/lib/images';
|
||||||
import { markdownToHtml } from '@/lib/markdown';
|
import { markdownToHtml } from '@/lib/markdown';
|
||||||
import { getBlogRoute } from '@/lib/routing';
|
import { getBlogRoute } from '@/lib/routing';
|
||||||
import { Image } from 'astro:assets';
|
import { Image } from 'astro:assets';
|
||||||
@@ -30,14 +30,17 @@ const blogs = await getAllPaginatedBlogs(settings, pageNumber);
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid grid-cols-2 gap-6">
|
<div class="grid grid-cols-2 gap-6">
|
||||||
{ blogs.map((blog) => (
|
{ blogs.map((blog) => {
|
||||||
|
const imageSize = getImageSize(blog.searchEngine.thumbnail.width, blog.searchEngine.thumbnail.height, 0.5);
|
||||||
|
|
||||||
|
return (
|
||||||
<a href={getBlogRoute(settings.blog, blog)} class={`flex flex-col gap-2`}>
|
<a href={getBlogRoute(settings.blog, blog)} class={`flex flex-col gap-2`}>
|
||||||
<Image
|
<Image
|
||||||
src={getImageUrl(blog.searchEngine.thumbnail.url)}
|
src={getImageUrl(blog.searchEngine.thumbnail.url)}
|
||||||
alt={blog.title}
|
alt={blog.title}
|
||||||
class="flex rounded-2xl shadow-md w-full"
|
class="flex rounded-2xl shadow-md w-full"
|
||||||
width={600}
|
width={imageSize.width}
|
||||||
height={315}
|
height={imageSize.height}
|
||||||
/>
|
/>
|
||||||
<div class="flex flex-col gap-1">
|
<div class="flex flex-col gap-1">
|
||||||
<h4 class="font-semibold text-[28px]">{blog.title}</h4>
|
<h4 class="font-semibold text-[28px]">{blog.title}</h4>
|
||||||
@@ -47,6 +50,8 @@ const blogs = await getAllPaginatedBlogs(settings, pageNumber);
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
)) }
|
)
|
||||||
|
|
||||||
|
}) }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
import CalendarIcon from '@/icons/CalendarIcon.astro';
|
import CalendarIcon from '@/icons/CalendarIcon.astro';
|
||||||
import { getImageUrl } from '@/lib/images';
|
import { getImageSize, getImageUrl } from '@/lib/images';
|
||||||
import { markdownToHtml } from '@/lib/markdown';
|
import { markdownToHtml } from '@/lib/markdown';
|
||||||
import { getTypographyClasses } from '@/styles/markdownClasses';
|
import { getTypographyClasses } from '@/styles/markdownClasses';
|
||||||
import { Image } from 'astro:assets';
|
import { Image } from 'astro:assets';
|
||||||
@@ -10,6 +10,8 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { blog } = Astro.props;
|
const { blog } = Astro.props;
|
||||||
|
|
||||||
|
const imageSize = getImageSize(blog.searchEngine.thumbnail.width, blog.searchEngine.thumbnail.height, 1);
|
||||||
---
|
---
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -29,8 +31,8 @@ const { blog } = Astro.props;
|
|||||||
<div class="w-full h-full rounded-2xl shadow-md object-cover">
|
<div class="w-full h-full rounded-2xl shadow-md object-cover">
|
||||||
<Image
|
<Image
|
||||||
src={getImageUrl(blog.searchEngine.thumbnail.url)}
|
src={getImageUrl(blog.searchEngine.thumbnail.url)}
|
||||||
width="1200"
|
width={imageSize.width}
|
||||||
height="630"
|
height={imageSize.height}
|
||||||
alt={blog.title}
|
alt={blog.title}
|
||||||
class="rounded-2xl"
|
class="rounded-2xl"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user