Skip to content

Commit 404f996

Browse files
authored
Improve asset version (#16)
1 parent 5749b3d commit 404f996

File tree

7 files changed

+36
-26
lines changed

7 files changed

+36
-26
lines changed

esbuild.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as esbuild from "esbuild";
22

33
const isProduction = process.env.NODE_ENV === "production";
44
const isWatch = process.argv.includes("--watch");
5+
const assetVersion = new Date().toISOString().slice(0, 10).replace(/-/g, '');
56

67
const config = {
78
entryPoints: ["src/main.js"],
@@ -18,6 +19,7 @@ const config = {
1819
isProduction ? "production" : "development",
1920
),
2021
"import.meta.env.BASE_PATH": JSON.stringify(process.env.BASE_PATH || ""),
22+
"import.meta.env.ASSET_VERSION": JSON.stringify(assetVersion),
2123
},
2224
};
2325

scripts/build-html.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { readFileSync, writeFileSync, mkdirSync } from 'fs';
22

33
const baseUrl = process.env.BASE_URL || 'https://conference.openapis.org';
4+
const assetVersion = new Date().toISOString().slice(0, 10).replace(/-/g, '');
45

56
// Ensure dist directory exists
67
mkdirSync('dist', { recursive: true });
78

89
// Read, replace, and write
910
let html = readFileSync('src/index.html', 'utf-8');
1011
html = html.replace(/__BASE_URL__/g, baseUrl);
12+
html = html.replace(/__ASSET_VERSION__/g, assetVersion);
1113
writeFileSync('dist/index.html', html);
1214

13-
console.log(`✅ HTML built with BASE_URL=${baseUrl}`);
15+
console.log(`✅ HTML built with BASE_URL=${baseUrl}, ASSET_VERSION=${assetVersion}`);

src/components/AgendaModal.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,15 @@ export class AgendaModal {
183183
<!-- Desktop: horizontal layout -->
184184
<div class="hidden tablet:flex items-center justify-between">
185185
<div class="flex items-center gap-4">
186-
<img
186+
${
187+
speaker.avatar
188+
? `<img
187189
src="${speaker.avatar}"
188190
alt="${speaker.name}"
189191
class="w-20 h-20 rounded-full object-cover"
190-
/>
192+
/>`
193+
: `<div class="w-20 h-20 rounded-full bg-primary-gray/30"></div>`
194+
}
191195
<div>
192196
<div class="flex items-center gap-2">
193197
<span class="font-bold text-text-primary uppercase tracking-wider leading-5">${
@@ -216,11 +220,15 @@ export class AgendaModal {
216220
217221
<!-- Mobile: vertical layout -->
218222
<div class="tablet:hidden">
219-
<img
223+
${
224+
speaker.avatar
225+
? `<img
220226
src="${speaker.avatar}"
221227
alt="${speaker.name}"
222228
class="w-12 h-12 object-cover mb-4 rounded-full"
223-
/>
229+
/>`
230+
: `<div class="w-12 h-12 mb-4 rounded-full bg-primary-gray/30"></div>`
231+
}
224232
<div class="flex items-center gap-2 mb-1">
225233
<span class="font-bold text-text-primary uppercase tracking-wider">${
226234
speaker.name

src/components/AgendaRenderer.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,14 @@ export class AgendaRenderer {
209209
item.speakers && item.speakers.length === 2
210210
? this.renderTwoSpeakers(item.speakers)
211211
: item.speakers && item.speakers.length > 0
212-
? item.speakers
213-
.map((speaker) => this.renderSpeakerInfo(speaker))
214-
.join("")
215-
: item.badge
216-
? `<div class="text-xs flex items-center text-primary-gray desktop:text-sm desktop-xxl:text-[16px] font-normal uppercase desktop-xl:-ml-6 desktop-xl:-mb-6 desktop-xxl:-ml-12 desktop-xxl:-mb-12 desktop-xl:h-20 tracking-widest group-hover:text-text-on-green transition-colors duration-200 ease-in-out">
212+
? item.speakers
213+
.map((speaker) => this.renderSpeakerInfo(speaker))
214+
.join("")
215+
: item.badge
216+
? `<div class="text-xs flex items-center text-primary-gray desktop:text-sm desktop-xxl:text-[16px] font-normal uppercase desktop-xl:-ml-6 desktop-xl:-mb-6 desktop-xxl:-ml-12 desktop-xxl:-mb-12 desktop-xl:h-20 tracking-widest group-hover:text-text-on-green transition-colors duration-200 ease-in-out">
217217
${item.badge}
218218
</div>`
219-
: ""
219+
: ""
220220
}
221221
</div>
222222
@@ -270,7 +270,7 @@ export class AgendaRenderer {
270270
const widths = this.calculateThreeBlockPercents(
271271
section.items[0].title,
272272
section.items[1].title,
273-
section.items[2].title
273+
section.items[2].title,
274274
);
275275

276276
itemsHtml = `
@@ -297,7 +297,7 @@ export class AgendaRenderer {
297297
if (section.items.length > 3) {
298298
const remainingWidths = this.calculateBlockPercents(
299299
section.items[3].title,
300-
""
300+
"",
301301
);
302302

303303
itemsHtml += `
@@ -314,7 +314,7 @@ export class AgendaRenderer {
314314
if (pair.length === 2) {
315315
const widths = this.calculateBlockPercents(
316316
pair[0].title,
317-
pair[1].title
317+
pair[1].title,
318318
);
319319
return `
320320
<div class="flex flex-col md:flex-row w-full h-auto tablet:h-[252px] desktop:h-[490px] pair-container">

src/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* Provides base path handling for assets
55
*/
66

7-
// Asset version for cache busting - increment when deploying changes
8-
const ASSET_VERSION = Date.now();
7+
// Asset version for cache busting - set to current date during build (YYYYMMDD format)
8+
const ASSET_VERSION = import.meta.env.ASSET_VERSION || Date.now();
99

1010
// BASE_PATH kept for backwards compatibility if used elsewhere
1111
const BASE_PATH = import.meta.env.BASE_PATH || "";

src/data/agenda.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const agendaSections = [
2020
description:
2121
"Join 600+ developers building new apps, bots — in person or online. Participants can build any app of their choice and will compete for $12,500+ in cash, products and prizes. Put yourself in the center of the developer world!",
2222
speakers: [],
23-
icon: asset("/images/hackathon.svg"),
2423
disableHover: true,
2524
},
2625
{
@@ -244,7 +243,6 @@ export const agendaSections = [
244243
description:
245244
"Official DeveloperWeek Closing Ceremony. Join us for closing remarks and a celebration of the day's achievements.",
246245
speakers: [],
247-
icon: asset("/images/closing.svg"),
248246
disableHover: true,
249247
},
250248
],

src/index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
/>
5252

5353
<!-- Favicon -->
54-
<link rel="icon" href="./images/favicons/favicon.png?v=2" />
54+
<link rel="icon" href="./images/favicons/favicon.png?v=__ASSET_VERSION__" />
5555

5656
<!-- License for San Jose background image -->
5757
<!-- Photo: "San Jose, California" by David Sawyer -->
@@ -81,7 +81,7 @@
8181
/>
8282

8383
<!-- Stylesheets -->
84-
<link rel="stylesheet" href="./output.css?v=2" />
84+
<link rel="stylesheet" href="./output.css?v=__ASSET_VERSION__" />
8585

8686
<!-- Theme Color -->
8787
<meta name="theme-color" content="#47c552" />
@@ -100,7 +100,7 @@
100100
<div class="max-w-[2440px] w-full">
101101
<!-- Header Hero Section -->
102102
<header
103-
class="flex flex-col tablet:flex-row h-[667px] tablet:min-h-0 tablet:h-[clamp(640px,50vw+160px,900px)] text-text-primary overflow-hidden desktop:h-[max(min(100vh,1166px),794px)] desktop-xl:h-[max(min(100vh,1117px),900px)] desktop-xxl:h-[max(min(100vh,1280px),1117px)]"
103+
class="flex flex-col tablet:flex-row h-[700px] tablet:min-h-0 tablet:h-[clamp(640px,50vw+160px,900px)] text-text-primary overflow-hidden desktop:h-[max(min(100vh,1166px),794px)] desktop-xl:h-[max(min(100vh,1117px),900px)] desktop-xxl:h-[max(min(100vh,1280px),1117px)]"
104104
>
105105
<!-- Left Content Container (2/3) -->
106106
<div
@@ -120,7 +120,7 @@
120120
>
121121
<a href="https://openapis.org" target="_blank" rel="noopener">
122122
<img
123-
src="./images/logo.svg?v=2"
123+
src="./images/logo.svg?v=__ASSET_VERSION__"
124124
alt="OpenAPI Conference Logo"
125125
class="w-40 tablet:w-[160px] tablet:h-[42px] desktop-xl:w-[273px] desktop-xl:h-[72px] h-10.5"
126126
/>
@@ -135,7 +135,7 @@
135135
rel="noopener noreferrer"
136136
>
137137
<img
138-
src="./images/developer_week_logo.svg?v=2"
138+
src="./images/developer_week_logo.svg?v=__ASSET_VERSION__"
139139
alt="Developer Week Logo"
140140
class="w-[82px] h-2 tablet:w-[149px] tablet:h-4 desktop-xxl:w-[119px] desktop-xxl:h-[62px]"
141141
/>
@@ -196,7 +196,7 @@
196196
rel="noopener noreferrer"
197197
class="tablet:hidden p-4 relative h-[152px] -mt-6 rounded-b-4xl overflow-hidden bg-cover bg-center block cursor-pointer"
198198
style="
199-
background-image: url(&quot;./images/background/background_top_right_san_jose.jpg?v=2&quot;);
199+
background-image: url(&quot;./images/background/background_top_right_san_jose.jpg?v=__ASSET_VERSION__&quot;);
200200
"
201201
>
202202
<!-- Dark Overlay -->
@@ -303,7 +303,7 @@
303303
<div
304304
class="w-full h-full absolute bg-cover bg-center bg-pan-slow"
305305
style="
306-
background-image: url(&quot;./images/background/background_top_right_san_jose.jpg?v=2&quot;);
306+
background-image: url(&quot;./images/background/background_top_right_san_jose.jpg?v=__ASSET_VERSION__&quot;);
307307
"
308308
></div>
309309

@@ -540,7 +540,7 @@
540540
</div>
541541

542542
<!-- JavaScript -->
543-
<script type="module" src="./main.js?v=2"></script>
543+
<script type="module" src="./main.js?v=__ASSET_VERSION__"></script>
544544

545545
<script
546546
async

0 commit comments

Comments
 (0)