mirror of
https://github.com/shadoll/sLogos.git
synced 2026-08-28 11:33:29 +00:00
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:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user