feat: trying to optimize builds

This commit is contained in:
Max Richter
2025-10-25 13:34:18 +02:00
parent cd59ecc22c
commit 2f08c7f4c2
7 changed files with 42 additions and 16 deletions

View File

@@ -65,6 +65,7 @@ const link = translatePath(`/${collection}/${id.split("/")[0]}`);
src={cover as ImageMetadata}
alt={"cover for " + title}
class="right-0 h-full object-cover object-center rounded-none border-l border-neutral"
thumbnail
/>
</a>
)

View File

@@ -12,6 +12,7 @@ interface Props {
hash?: boolean;
loader?: boolean;
maxWidth?: number;
thumbnail?: boolean;
}
async function checkImage(image: ImageMetadata) {
@@ -41,16 +42,17 @@ const {
hash = true,
alt,
maxWidth,
thumbnail = false,
} = Astro.props;
const imageOk = await checkImage(image);
const imageBuffer = imageOk && await getImageBuffer(image);
const imageBuffer = imageOk && (await getImageBuffer(image));
let thumbhash = imageBuffer && (await generateThumbHash(imageBuffer));
let exif = imageBuffer && (await getExifData(imageBuffer));
const sizes = [
const definedSizes = [
{
width: 240,
media: "(max-width: 360px)",
@@ -66,7 +68,11 @@ const sizes = [
{
width: image.width,
},
].filter((size) => !maxWidth || size.width <= maxWidth);
];
const sizes = thumbnail
? [definedSizes[0]]
: definedSizes.filter((size) => !maxWidth || size.width <= maxWidth);
---
{

View File

@@ -1,13 +1,20 @@
---
interface Props {
title: string;
cover: string;
cover?: string;
description?: string;
}
const {
title,
cover,
description = "A personal blog and portfolio by Max Richter.",
} = Astro.props;
---
<meta property="og:title" content={Astro.props.title} />
<meta property="og:title" content={title} />
<meta property="og:type" content="website" />
<meta property="og:url" content={Astro.url} />
<meta property="og:image" content={Astro.props.cover} />
<meta property="og:description" content="Max Richters personal blog" />
{cover && <meta property="og:image" content={cover} />}
<meta property="og:description" content={description} />
<meta property="og:site_name" content="Max Richter" />

View File

@@ -3,6 +3,7 @@ import { getCollection, render } from "astro:content";
import { getLocale } from "astro-i18n-aut";
import { filterCollection, parseSlug } from "@i18n/utils";
import MetaTags from "@components/MetaTags.astro";
import { markdownToText } from "@helpers/markdown";
const locale = getLocale(Astro.url);
@@ -32,5 +33,9 @@ if (!page) {
const { Content } = await render(page);
---
<MetaTags title={page.data.title} cover={page.data.cover?.src} />
<MetaTags
title={page.data.title}
cover={page.data.cover?.src}
description={page.data.description || markdownToText(page.body).slice(0, 200)}
/>
<Content />

View File

@@ -3,6 +3,7 @@ import { getCollection, render } from "astro:content";
import { getLocale } from "astro-i18n-aut";
import { filterCollection, parseSlug } from "@i18n/utils";
import MetaTags from "@components/MetaTags.astro";
import { markdownToText } from "@helpers/markdown";
const locale = getLocale(Astro.url);
@@ -32,5 +33,9 @@ if (!page) {
const { Content } = await render(page);
---
<MetaTags title={page.data.title} cover={page.data.cover?.src} />
<MetaTags
title={page.data.title}
cover={page.data.cover?.src}
description={page.data.description || markdownToText(page.body).slice(0, 200)}
/>
<Content />