From 187686c94c5afd58f5069b05ba3fe3879cc6494d Mon Sep 17 00:00:00 2001 From: SepComet <202308010230@stu.csust.edu.cn> Date: Thu, 7 May 2026 14:34:08 +0800 Subject: [PATCH] Make the corner gallery resolve gallery files reliably Use the project root as the anchor so the homepage sticker gallery survives Astro build and still randomizes from public/images/gallery. Constraint: Keep behavior unchanged except for build-time discovery. Rejected: import.meta.url-based directory lookup | it failed in production build. Confidence: high Scope-risk: narrow Directive: Preserve the gallery scan as a static build-time concern unless the deployment model changes. Tested: npm run build; verified dist/index.html contains corner-gallery and gallery image paths Not-tested: browser repaint timing in a live session --- src/components/RandomCornerImage.astro | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/RandomCornerImage.astro b/src/components/RandomCornerImage.astro index 7785dbb..b1caa61 100644 --- a/src/components/RandomCornerImage.astro +++ b/src/components/RandomCornerImage.astro @@ -1,11 +1,8 @@ --- import fs from 'node:fs'; import path from 'node:path'; -import { fileURLToPath } from 'node:url'; -const galleryDirectory = fileURLToPath( - new URL('../../public/images/gallery', import.meta.url), -); +const galleryDirectory = path.resolve(process.cwd(), 'public', 'images', 'gallery'); const supportedExtensions = new Set([ '.avif',