From 2f08c7f4c2e04fe9a969536a063ee71d2683512f Mon Sep 17 00:00:00 2001 From: Max Richter Date: Sat, 25 Oct 2025 13:34:18 +0200 Subject: [PATCH] feat: trying to optimize builds --- .github/workflows/default.yaml | 16 +++++++++------- src/components/HeroCard.astro | 1 + src/components/Image.astro | 12 +++++++++--- src/components/MetaTags.astro | 15 +++++++++++---- src/components/Tag.astro | 0 src/pages/blog/[slug].astro | 7 ++++++- src/pages/photos/[slug].astro | 7 ++++++- 7 files changed, 42 insertions(+), 16 deletions(-) delete mode 100644 src/components/Tag.astro diff --git a/.github/workflows/default.yaml b/.github/workflows/default.yaml index b95a36e..a7f1542 100644 --- a/.github/workflows/default.yaml +++ b/.github/workflows/default.yaml @@ -20,15 +20,13 @@ jobs: - name: 🔄 Checkout code uses: actions/checkout@v3 - - name: 🔢 Calculate cache IDs + - name: 🔢 Prepare cache keys run: | - # Calculate cache IDs for Git LFS and PNPM + # Calculate cache IDs for Git LFS git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id LFS_CACHE_ID=$(cat .lfs-assets-id | md5sum)-v1 - PNPM_CACHE_ID=$(cat pnpm-lock.yaml | md5sum)-v1 echo "LFS_CACHE_ID=$LFS_CACHE_ID" >> $GITHUB_ENV echo "PNPM_STORE_PATH=$(pnpm store path)" >> $GITHUB_ENV - echo "PNPM_CACHE_ID=$PNPM_CACHE_ID" >> $GITHUB_ENV - name: 🗄️ Cache Git LFS objects uses: actions/cache@v4 @@ -41,12 +39,16 @@ jobs: with: path: ${{ env.PNPM_STORE_PATH }} key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: 📷 Cache Astro Images uses: actions/cache@v4 with: path: node_modules/.astro - key: ${{ runner.os }}-astro-v1 + key: ${{ runner.os }}-astro-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-astro- - name: 🔄 Pull Git LFS files run: git lfs pull @@ -70,8 +72,8 @@ jobs: - name: 🚀 Deploy Changed Files via rclone run: | echo "Uploading _astro assets" - rclone sync --update -v --progress --size-only --stats 2s --stats-one-line ./dist/_astro sftp-remote:${REMOTE_DIR}/_astro --transfers 4 + rclone sync --update -v --progress --size-only --fast-list --stats 2s --stats-one-line ./dist/_astro sftp-remote:${REMOTE_DIR}/_astro --transfers 4 echo "Uploading the rest" - rclone sync --update -v --progress --exclude _astro/** --stats 2s --stats-one-line ./dist/ sftp-remote:${REMOTE_DIR} --transfers 4 + rclone sync --update -v --progress --exclude _astro/** --fast-list --stats 2s --stats-one-line ./dist/ sftp-remote:${REMOTE_DIR} --transfers 4 env: REMOTE_DIR: ${{ vars.REMOTE_DIR }} diff --git a/src/components/HeroCard.astro b/src/components/HeroCard.astro index 8f1857f..9d8bf76 100644 --- a/src/components/HeroCard.astro +++ b/src/components/HeroCard.astro @@ -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 /> ) diff --git a/src/components/Image.astro b/src/components/Image.astro index 4f8f8a9..5e47874 100644 --- a/src/components/Image.astro +++ b/src/components/Image.astro @@ -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); --- { diff --git a/src/components/MetaTags.astro b/src/components/MetaTags.astro index f5dc172..2864703 100644 --- a/src/components/MetaTags.astro +++ b/src/components/MetaTags.astro @@ -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; --- - + - - +{cover && } + diff --git a/src/components/Tag.astro b/src/components/Tag.astro deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/blog/[slug].astro b/src/pages/blog/[slug].astro index 846e0f2..883e507 100644 --- a/src/pages/blog/[slug].astro +++ b/src/pages/blog/[slug].astro @@ -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); --- - + diff --git a/src/pages/photos/[slug].astro b/src/pages/photos/[slug].astro index 0942a76..2f3a98b 100644 --- a/src/pages/photos/[slug].astro +++ b/src/pages/photos/[slug].astro @@ -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); --- - +