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
This commit is contained in:
SepComet 2026-05-07 14:34:08 +08:00
parent f0397730e6
commit 187686c94c
1 changed files with 1 additions and 4 deletions

View File

@ -1,11 +1,8 @@
--- ---
import fs from 'node:fs'; import fs from 'node:fs';
import path from 'node:path'; import path from 'node:path';
import { fileURLToPath } from 'node:url';
const galleryDirectory = fileURLToPath( const galleryDirectory = path.resolve(process.cwd(), 'public', 'images', 'gallery');
new URL('../../public/images/gallery', import.meta.url),
);
const supportedExtensions = new Set([ const supportedExtensions = new Set([
'.avif', '.avif',