Refactor PWA caching and image generation scripts

- Updated `generate-pwa-cache-list.js` to include images directory and remove duplicate file entries.
- Refactored `generate-svg-variants.js` to utilize collections from a centralized source and renamed generation directory variable.
- Modified `update-data.js` to align with new directory structure for images and variants, ensuring proper paths are used.
- Adjusted `collections.js` to standardize directory naming for variants.
- Enhanced Svelte components (`Actions.svelte`, `CardFull.svelte`, `CardMiddle.svelte`, `CardSmall.svelte`, `CardTiny.svelte`) to utilize context for collection management, simplifying image URL generation.
This commit is contained in:
sha
2025-06-18 13:18:15 +03:00
parent d7feb6db19
commit 4a32deaeb5
12 changed files with 108 additions and 1622 deletions
+11 -3
View File
@@ -4,6 +4,7 @@
import ColorSwitcher from "./ColorSwitcher.svelte";
import { getDefaultLogoColor } from "../utils/colorTheme.js";
import { collections } from '../collections.js';
import { getContext } from 'svelte';
export let logo;
export let theme;
@@ -31,9 +32,16 @@
return collection ? collection.baseDir : 'images/logos';
}
let collection = getContext('collection');
if (!collection) {
if (typeof window !== 'undefined' && window.appData && window.appData.collection) {
collection = collections.find(c => c.name === window.appData.collection) || collections[0];
} else {
collection = collections[0];
}
}
function getImageUrl(logo) {
const baseDir = getBaseDir(logo);
return `/${baseDir}/${logo.path.split('/').pop()}`;
return `/${collection.baseDir}/${logo.path}`;
}
$: getLogoThemeColor = (logo) => getDefaultLogoColor(logo.colors, theme);
@@ -69,7 +77,7 @@
/>
{/key}
{:else}
<img src={getImageUrl(logo)} alt={logo.title || logo.name}/>
<img src={getImageUrl(logo)} alt={logo.title || logo.name} />
{/if}
</div>
<div class="logo-info">