site: list mosaic tiles for /finds/ + home grid
Adds a build-time mosaic generator (scripts/build-list-mosaics.mjs, sharp) that composites a single tile image per superpost from its referenced finds. Wired via predev/prestart/prebuild hooks; output lives in src/generated/ (gitignored). The /finds/ index and home grid both render the mosaic when present and fall back to text-only tiles otherwise.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import type { ImageMetadata } from 'astro';
|
||||
|
||||
const modules = import.meta.glob<{ default: ImageMetadata }>(
|
||||
'../generated/list-mosaics/*.jpg',
|
||||
{ eager: true }
|
||||
);
|
||||
|
||||
const mosaics = new Map<string, ImageMetadata>();
|
||||
for (const [path, mod] of Object.entries(modules)) {
|
||||
const match = path.match(/list-mosaics\/([^/]+)\.jpg$/);
|
||||
if (match) mosaics.set(match[1], mod.default);
|
||||
}
|
||||
|
||||
export function findListMosaic(slug: string): ImageMetadata | undefined {
|
||||
return mosaics.get(slug);
|
||||
}
|
||||
Reference in New Issue
Block a user