File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11---
2+ import { readdir } from ' node:fs/promises' ;
3+ import path from ' node:path' ;
24import BaseLayout from ' ../layouts/BaseLayout.astro' ;
35
4- // Auto-discovers every file in public/stamps/ at build time.
5- const stampModules = import .meta .glob (' /public/stamps/*' );
6- const stamps = Object .keys (stampModules ).map (path => path .replace (' /public' , ' ' ));
6+ // Auto-discovers every stamp in public/stamps/ at build time.
7+ // Plain readdir instead of import.meta.glob: globbing public/ makes Vite
8+ // emit a second hashed copy of every stamp into dist/_astro/ that nothing uses.
9+ const stampDir = path .join (process .cwd (), ' public/stamps' );
10+ const stampFiles = (await readdir (stampDir ))
11+ .filter (f => / \. (png| gif| jpe? g| webp| avif)$ / i .test (f ))
12+ .sort ();
13+ const stamps = stampFiles .map (f => ` /stamps/${f } ` );
714
815// The seamless loop works by animating translateX(-50%) across a set rendered twice.
916// That only works if one set is wider than the visible bar (~1300px).
1017// So we pad the array up to at least 30 entries before doubling it.
1118const MIN_STAMPS = 30 ;
12- const copies = Math .ceil (MIN_STAMPS / stamps .length );
19+ const copies = stamps . length ? Math .ceil (MIN_STAMPS / stamps .length ) : 0 ;
1320const paddedStamps = Array (copies ).fill (stamps ).flat ();
1421---
1522
You can’t perform that action at this time.
0 commit comments