feat(ui): add photo file handling in Vite config
* include new image assets in static/photos * define __PHOTO_FILES__ for dynamic photo URLs * update package.json and package-lock.json with @types/node
This commit is contained in:
Vendored
+3
@@ -8,6 +8,9 @@ declare global {
|
||||
// interface PageState {}
|
||||
// interface Platform {}
|
||||
}
|
||||
|
||||
// Filenames in static/photos, injected at build time (see vite.config.ts).
|
||||
const __PHOTO_FILES__: string[];
|
||||
}
|
||||
|
||||
export {};
|
||||
|
||||
@@ -2,14 +2,9 @@
|
||||
import { backOut, cubicIn } from "svelte/easing";
|
||||
import { browser } from "$app/environment";
|
||||
|
||||
const modules = import.meta.glob(
|
||||
"../../../assets/photos/*.{jpg,jpeg,png,JPG,JPEG,PNG}",
|
||||
{
|
||||
eager: true,
|
||||
import: "default",
|
||||
query: "?url",
|
||||
},
|
||||
) as Record<string, string>;
|
||||
const photoUrls = __PHOTO_FILES__.map(
|
||||
(name) => `/photos/${encodeURIComponent(name)}`,
|
||||
);
|
||||
|
||||
function shuffle<T>(items: T[]): T[] {
|
||||
const result = [...items];
|
||||
@@ -56,7 +51,7 @@
|
||||
|
||||
$effect(() => {
|
||||
if (!browser) return;
|
||||
photos = shuffle(Object.values(modules));
|
||||
photos = shuffle(photoUrls);
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
|
||||
Reference in New Issue
Block a user