Skip to content

Commit 5420128

Browse files
authored
Fix plan image caching (#921)
1 parent a761d2a commit 5420128

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

src/routes/plans/+page.svelte

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script>
2-
import { asset } from '$app/paths';
32
import BottomNavigationBar from '$lib/components/BottomNavigationBar.svelte';
43
import Navbar from '$lib/components/Navbar.svelte';
54
import config from '$lib/data/config';
@@ -9,7 +8,17 @@
98
import { compareVersions } from '$lib/scripts/stringUtils';
109
1110
const imageFolder =
12-
compareVersions(config.programVersion, '12.0') < 0 ? 'illustrations' : 'plans';
11+
compareVersions(config.programVersion, '12.0') < 0
12+
? import.meta.glob('./*', {
13+
eager: true,
14+
import: 'default',
15+
base: '/src/gen-assets/illustrations'
16+
})
17+
: import.meta.glob(['./*', '!./*.json'], {
18+
eager: true,
19+
import: 'default',
20+
base: '/src/gen-assets/plans'
21+
});
1322
1423
let selectedTab = $state('available');
1524
let availablePlans = $state([]);
@@ -116,7 +125,7 @@
116125
<div class="plan-image-block">
117126
<img
118127
class="plan-image"
119-
src={asset(`/${imageFolder}/${plan.image.file}`)}
128+
src={imageFolder[`./${plan.image.file}`]}
120129
alt={plan.image.file}
121130
width={plan.image.width}
122131
height={plan.image.height}
@@ -148,7 +157,7 @@
148157
<div class="plan-image-block">
149158
<img
150159
class="plan-image"
151-
src={asset(`/${imageFolder}/${plan.image.file}`)}
160+
src={imageFolder[`./${plan.image.file}`]}
152161
alt={plan.image.file}
153162
width={plan.image.width}
154163
height={plan.image.height}
@@ -180,7 +189,7 @@
180189
<div class="plan-image-block">
181190
<img
182191
class="plan-image"
183-
src={asset(`/${imageFolder}/${plan.image.file}`)}
192+
src={imageFolder[`./${plan.image.file}`]}
184193
alt={plan.image.file}
185194
width={plan.image.width}
186195
height={plan.image.height}

0 commit comments

Comments
 (0)