-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstore-item.html
More file actions
569 lines (511 loc) · 23.1 KB
/
store-item.html
File metadata and controls
569 lines (511 loc) · 23.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Patch — plugdata Store</title>
<link rel="icon" href="assets/plugdata-logo.png" type="image/png" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="styles.css" />
<style>
/* Back link */
.back-link {
display: inline-flex; align-items: center; gap: 0.375rem;
font-size: 0.8125rem; font-weight: 500;
color: hsl(var(--muted-foreground));
margin-bottom: 2rem;
text-decoration: none;
transition: color 0.15s;
}
.back-link:hover { color: hsl(var(--foreground)); }
/* Price badge */
.price-badge {
display: inline-flex; align-items: center;
padding: 0.3rem 0.75rem;
font-size: 0.8125rem; font-weight: 500;
border-radius: 9999px;
background: hsl(var(--primary-soft));
color: hsl(var(--primary));
border: 1px solid hsl(var(--primary) / 0.25);
}
.price-badge.free {
background: hsl(140 60% 95%);
color: hsl(140 55% 28%);
border-color: hsl(140 50% 55% / 0.4);
}
/* Screenshot */
.screenshot-frame {
border-radius: 0.75rem; overflow: hidden;
border: 1px solid hsl(var(--border));
background: hsl(var(--secondary) / 0.4);
box-shadow: var(--shadow-soft);
}
.screenshot-frame img {
width: 100%; height: auto; display: block;
}
/* Item sidebar (price, download, meta) */
.item-sidebar { display: flex; flex-direction: column; gap: 1.25rem; }
.item-sidebar .download-row {
display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem;
}
/* Split download button */
.download-split {
position: relative; display: inline-flex; align-items: stretch;
}
.download-split .btn { white-space: nowrap; }
.download-split .main {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
padding-right: 1.125rem;
}
.download-split .toggle {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-left: 1px solid hsl(0 0% 100% / 0.18);
padding: 0 0.75rem;
}
.download-menu {
position: absolute; top: calc(100% + 0.5rem); right: 0;
min-width: 15rem;
background: hsl(var(--card));
border: 1px solid hsl(var(--border));
border-radius: 0.5rem;
padding: 0.3rem;
box-shadow: var(--shadow-soft);
z-index: 20;
}
.download-menu[hidden] { display: none; }
.download-menu-item {
display: flex; align-items: center; gap: 0.625rem;
padding: 0.55rem 0.625rem;
font-size: 0.875rem;
color: hsl(var(--foreground));
text-decoration: none;
border-radius: 0.375rem;
cursor: pointer;
}
.download-menu-item:hover { background: hsl(var(--secondary)); }
.download-menu-item svg { color: hsl(var(--muted-foreground)); flex: 0 0 auto; }
/* Info meta list */
.item-meta {
margin-top: 0.5rem;
display: flex; flex-direction: column;
gap: 0.75rem;
padding-top: 1.25rem;
border-top: 1px solid hsl(var(--border));
}
.item-meta-row {
display: flex; align-items: center; gap: 0.75rem;
font-size: 0.875rem;
}
.item-meta-row > svg { color: hsl(var(--muted-foreground) / 0.8); flex: 0 0 auto; }
.item-meta-row .label {
color: hsl(var(--muted-foreground));
}
.item-meta-row .value {
margin-left: auto; font-weight: 500;
font-family: var(--font-mono);
font-size: 0.8125rem;
color: hsl(var(--foreground));
}
/* Description prose — lives in the sidebar now */
.item-description {
font-size: 0.9375rem; line-height: 1.65;
color: hsl(var(--foreground));
white-space: pre-wrap;
padding-top: 1.25rem;
border-top: 1px solid hsl(var(--border));
}
.item-description:empty { display: none; }
/* Reuse store-item card style from store.html */
a.store-item {
text-decoration: none; color: inherit;
transition: transform 0.15s ease, border-color 0.15s, box-shadow 0.15s;
}
a.store-item:hover {
border-color: hsl(var(--foreground) / 0.2);
box-shadow: var(--shadow-soft);
transform: translateY(-1px);
}
a.store-item .preview { background: hsl(var(--secondary) / 0.4); overflow: hidden; }
a.store-item .preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
a.store-item h3 { font-size: 0.9375rem; line-height: 1.3; overflow-wrap: anywhere; }
a.store-item .row { align-items: baseline; }
a.store-item .price { flex: 0 0 auto; white-space: nowrap; }
a.store-item .author {
margin-top: 0.125rem; font-size: 0.75rem;
color: hsl(var(--muted-foreground));
}
/* Override feature-card pad for a narrower gap at this use */
.split.item-split { grid-template-columns: 1fr; gap: 2rem; }
@media (min-width: 1024px) {
.split.item-split { grid-template-columns: 7fr 5fr; gap: 2.5rem; align-items: start; }
}
/* Not-found / error state */
.empty-section {
text-align: center; padding: 3rem 1rem;
color: hsl(var(--muted-foreground));
}
.empty-section h2 { color: hsl(var(--foreground)); margin-bottom: 0.5rem; }
.empty-section p { margin-bottom: 1.5rem; font-size: 0.9375rem; }
[data-hide-until-loaded] { visibility: hidden; }
[data-loaded] [data-hide-until-loaded] { visibility: visible; }
</style>
</head>
<body>
<header class="site-header">
<div class="container">
<div class="bar">
<a href="index.html" class="brand"><img src="assets/plugdata-logo.png" alt=""/><span>plugdata</span></a>
<nav class="nav" aria-label="Primary">
<a href="index.html" data-nav-link>Home</a>
<a href="about.html" data-nav-link>About</a>
<a href="download.html" data-nav-link>Download</a>
<a href="documentation.html" data-nav-link>Documentation</a>
<a href="support.html" data-nav-link>Support</a>
<a href="store.html" data-nav-link>Store</a>
</nav>
<div class="icon-links">
<a class="icon-btn" href="https://github.com/plugdata-team/plugdata" target="_blank" rel="noreferrer" aria-label="GitHub"><svg width="16" height="16" viewBox="0 0 1024 1024" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8C0 11.54 2.29 14.53 5.47 15.59C5.87 15.66 6.02 15.42 6.02 15.21C6.02 15.02 6.01 14.39 6.01 13.72C4 14.09 3.48 13.23 3.32 12.78C3.23 12.55 2.84 11.84 2.5 11.65C2.22 11.5 1.82 11.13 2.49 11.12C3.12 11.11 3.57 11.7 3.72 11.94C4.44 13.15 5.59 12.81 6.05 12.6C6.12 12.08 6.33 11.73 6.56 11.53C4.78 11.33 2.92 10.64 2.92 7.58C2.92 6.71 3.23 5.99 3.74 5.43C3.66 5.23 3.38 4.41 3.82 3.31C3.82 3.31 4.49 3.1 6.02 4.13C6.66 3.95 7.34 3.86 8.02 3.86C8.7 3.86 9.38 3.95 10.02 4.13C11.55 3.09 12.22 3.31 12.22 3.31C12.66 4.41 12.38 5.23 12.3 5.43C12.81 5.99 13.12 6.7 13.12 7.58C13.12 10.65 11.25 11.33 9.47 11.53C9.76 11.78 10.01 12.26 10.01 13.01C10.01 14.08 10 14.94 10 15.21C10 15.42 10.15 15.67 10.55 15.59C13.71 14.53 16 11.53 16 8C16 3.58 12.42 0 8 0Z" transform="scale(64)" fill="#1B1F23"/>
</svg></a>
<a class="icon-btn" href="https://discord.gg/eT2RxdF9Nq" target="_blank" rel="noreferrer" aria-label="Discord"><svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor"><path d="M19.27 5.33A18 18 0 0 0 14.9 4l-.2.42a16.6 16.6 0 0 0-4.9 0L9.6 4a18 18 0 0 0-4.37 1.33C2.5 9.32 1.76 13.2 2.13 17a18.5 18.5 0 0 0 5.6 2.83l.45-.62a13 13 0 0 1-2.13-1.03l.52-.41a13 13 0 0 0 11.16 0l.52.41c-.66.4-1.38.74-2.13 1.03l.45.62A18.5 18.5 0 0 0 21.87 17c.46-4.55-.74-8.4-2.6-11.67zM9.34 14.6a1.78 1.78 0 0 1-1.66-1.86 1.7 1.7 0 1 1 3.32 0c0 1.03-.74 1.86-1.66 1.86zm5.32 0a1.78 1.78 0 0 1-1.66-1.86 1.7 1.7 0 1 1 3.32 0c0 1.03-.74 1.86-1.66 1.86z"/></svg></a>
</div>
<button class="icon-btn menu-toggle" data-menu-toggle aria-label="Menu"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"><path d="M4 7h16M4 12h16M4 17h16"/></svg></button>
</div>
<nav class="mobile-nav" data-mobile-nav>
<a href="index.html" data-nav-link>Home</a>
<a href="about.html" data-nav-link>About</a>
<a href="download.html" data-nav-link>Download</a>
<a href="documentation.html" data-nav-link>Documentation</a>
<a href="support.html" data-nav-link>Support</a>
<a href="store.html" data-nav-link>Store</a>
</nav>
</div>
</header>
<main data-page-state="loading">
<!-- Loading state — replaced by item content once fetched -->
<div data-section="loading">
<section class="page-hero">
<div class="dot-grid-fade"></div>
<div class="container">
<div class="inner">
<p class="eyebrow">Store</p>
<h1 class="text-balance">Loading…</h1>
</div>
</div>
</section>
</div>
<!-- Not-found state -->
<div data-section="not-found" hidden>
<section class="page-hero">
<div class="dot-grid-fade"></div>
<div class="container">
<div class="inner">
<a href="store.html" class="back-link">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"/></svg>
Back to store
</a>
<p class="eyebrow">Store</p>
<h1 class="text-balance">Patch not found</h1>
<p class="sub">We couldn't find that patch. It may have been removed, or the link might be incorrect.</p>
</div>
</div>
</section>
</div>
<!-- Item content — revealed once data loads -->
<div data-section="item" hidden>
<section class="page-hero">
<div class="dot-grid-fade"></div>
<div class="container">
<div class="inner">
<a href="store.html" class="back-link">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round""><polyline points="15 18 9 12 15 6"/></svg>
Back to store
</a>
<p class="eyebrow">Store</p>
<h1 class="text-balance" data-item-title></h1>
<p class="sub" data-item-author></p>
</div>
</div>
</section>
<section class="section" style="padding-top: 3rem;">
<div class="container">
<div class="split item-split">
<div class="screenshot-frame">
<img data-item-thumb src="" alt="" />
</div>
<aside class="item-sidebar">
<div data-price-slot></div>
<div class="download-row" data-item-actions></div>
<div class="item-meta" data-item-meta></div>
<div class="item-description" data-item-description></div>
</aside>
</div>
</div>
</section>
<section class="section">
<div class="container">
<div class="section-head">
<p class="eyebrow" style="margin-bottom: 0.75rem;">More</p>
<h2 data-related-heading>More patches</h2>
</div>
<div class="store-grid" data-related-grid></div>
</div>
</section>
</div>
</main>
<footer class="site-footer">
<div class="container">
<div class="top">
<div><a href="index.html" class="brand"><img src="assets/plugdata-logo.png" alt="" width="28" height="28" /><span>plugdata</span></a><p class="blurb">A free, open-source visual programming environment for audio.</p></div>
<div><h4>Project</h4><ul><li><a href="about.html">About</a></li><li><a href="documentation.html">Documentation</a></li><li><a href="support.html">Support</a></li></ul></div>
<div><h4>Get plugdata</h4><ul><li><a href="download.html">Download</a></li><li><a href="store.html">Store</a></li><li><a href="https://github.com/plugdata-team/plugdata/releases" target="_blank" rel="noreferrer">Releases</a></li></ul></div>
<div><h4>Community</h4><ul><li><a href="https://github.com/plugdata-team/plugdata" target="_blank" rel="noreferrer">GitHub</a></li><li><a href="https://discord.gg/eT2RxdF9Nq" target="_blank" rel="noreferrer">Discord</a></li><li><a href="https://github.com/sponsors/timothyschoen" target="_blank" rel="noreferrer">Sponsor</a></li></ul></div>
</div>
<div class="bottom"><p class="copy">© <span data-year>2025</span> plugdata. Released under the GPL-3.0 license. Based on Pure Data by Miller Puckette.</p></div>
</div>
</footer>
<script src="main.js"></script>
<script>
(function () {
const main = document.querySelector('main');
const sections = {
loading: document.querySelector('[data-section="loading"]'),
notFound: document.querySelector('[data-section="not-found"]'),
item: document.querySelector('[data-section="item"]')
};
function showSection(which) {
Object.keys(sections).forEach(k => {
sections[k].hidden = (k !== which);
});
main.dataset.pageState = which;
}
function esc(s) {
return String(s == null ? '' : s).replace(/[&<>"']/g, c => ({
'&': '&', '<': '<', '>': '>', '"': '"', "'": '''
}[c]));
}
function thumbUrl(name) {
return 'thumbnails/webp/' + encodeURIComponent(name) + '.webp';
}
function itemHref(title) {
return 'store-item.html?id=' + encodeURIComponent(title);
}
function downloadHelperUrl(item, type) {
const p = new URLSearchParams();
p.set('title', item.Title);
p.set('download', item.Download);
p.set('type', type);
return 'store-download.html?' + p.toString();
}
const urlParams = new URLSearchParams(window.location.search);
const itemId = urlParams.get('id');
if (!itemId) {
showSection('notFound');
return;
}
fetch('store.json')
.then(r => {
if (!r.ok) throw new Error('HTTP ' + r.status);
return r.json();
})
.then(data => {
const patches = (data && data.Patches) || [];
const item = patches.find(p => p.Title === itemId);
if (!item) {
showSection('notFound');
return;
}
renderItem(item, patches);
showSection('item');
})
.catch(err => {
console.error('Error loading store.json:', err);
showSection('notFound');
});
// ---------- Rendering ----------
function renderItem(item, allPatches) {
document.title = item.Title + ' — plugdata Store';
// Title + author
document.querySelector('[data-item-title]').textContent = item.Title;
const authorEl = document.querySelector('[data-item-author]');
authorEl.textContent = item.Author ? 'By ' + item.Author : '';
// Thumbnail
const thumbEl = document.querySelector('[data-item-thumb]');
if (item.StoreThumb) {
thumbEl.src = thumbUrl(item.StoreThumb);
thumbEl.alt = item.Title;
}
// Description (preserves line breaks via white-space: pre-wrap in CSS)
document.querySelector('[data-item-description]').textContent = item.Description || '';
// Price badge
renderPriceBadge(item);
// Download actions
renderActions(item);
// Meta list (release date / size)
renderMeta(item);
// Related patches
renderRelated(item, allPatches);
}
function renderPriceBadge(item) {
const slot = document.querySelector('[data-price-slot]');
if (!item.Price) { slot.innerHTML = ''; return; }
const isFree = /^free$/i.test(String(item.Price).trim());
slot.innerHTML =
'<span class="price-badge' + (isFree ? ' free' : '') + '">' + esc(item.Price) + '</span>';
}
function renderActions(item) {
const holder = document.querySelector('[data-item-actions]');
const download = String(item.Download || '');
const canDirect = /^free$/i.test(String(item.Price || '').trim()) &&
(download.toLowerCase().endsWith('.zip') || download.toLowerCase().endsWith('.plugdata'));
if (canDirect) {
holder.innerHTML = `
<div class="download-split">
<button type="button" class="btn btn-primary lg main" data-dl-main>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
<span>Download</span>
</button>
<button type="button" class="btn btn-primary lg toggle" data-dl-toggle aria-label="More download options" aria-haspopup="true" aria-expanded="false">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>
</button>
<div class="download-menu" data-dl-menu hidden role="menu">
<a href="#" class="download-menu-item" data-dl-plugdata role="menuitem">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>
Download as .plugdata
</a>
<a href="#" class="download-menu-item" data-dl-zip role="menuitem">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="12" y1="3" x2="12" y2="7"/><line x1="12" y1="10" x2="12" y2="14"/><line x1="12" y1="17" x2="12" y2="21"/></svg>
Download as .zip
</a>
</div>
</div>
`;
const mainBtn = holder.querySelector('[data-dl-main]');
const toggleBtn = holder.querySelector('[data-dl-toggle]');
const menu = holder.querySelector('[data-dl-menu]');
const optPlug = holder.querySelector('[data-dl-plugdata]');
const optZip = holder.querySelector('[data-dl-zip]');
// Main button: replicate old behaviour — open raw download + open helper for .plugdata
mainBtn.addEventListener('click', () => {
window.open(item.Download, '_blank');
window.open(downloadHelperUrl(item, 'plugdata'), '_blank');
});
// Dropdown toggle
toggleBtn.addEventListener('click', e => {
e.stopPropagation();
const isOpen = !menu.hidden;
menu.hidden = isOpen;
toggleBtn.setAttribute('aria-expanded', String(!isOpen));
});
// Close when clicking outside
document.addEventListener('click', () => {
menu.hidden = true;
toggleBtn.setAttribute('aria-expanded', 'false');
});
// Plugdata option: just the helper
optPlug.addEventListener('click', e => {
e.preventDefault();
window.open(downloadHelperUrl(item, 'plugdata'), '_blank');
menu.hidden = true;
toggleBtn.setAttribute('aria-expanded', 'false');
});
// Zip option: raw download + confirmation helper
optZip.addEventListener('click', e => {
e.preventDefault();
window.open(item.Download, '_blank');
window.open(downloadHelperUrl(item, 'zip'), '_blank');
menu.hidden = true;
toggleBtn.setAttribute('aria-expanded', 'false');
});
} else {
// Paid or external — single "Go to store" link
holder.innerHTML = `
<a class="btn btn-primary lg" href="${esc(item.Download)}" target="_blank" rel="noreferrer">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>
<span>Go to store</span>
</a>
`;
}
}
function renderMeta(item) {
const el = document.querySelector('[data-item-meta]');
const rows = [];
if (item['Release date']) {
rows.push({
label: 'Released',
value: item['Release date'],
icon: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>'
});
}
if (item.Size) {
rows.push({
label: 'Size',
value: item.Size,
icon: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="20" height="14" rx="2" ry="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/></svg>'
});
}
if (item.Author) {
rows.push({
label: 'Author',
value: item.Author,
icon: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>'
});
}
if (!rows.length) {
el.style.display = 'none';
return;
}
el.style.display = '';
el.innerHTML = rows.map(r => `
<div class="item-meta-row">
${r.icon}
<span class="label">${esc(r.label)}</span>
<span class="value">${esc(r.value)}</span>
</div>
`).join('');
}
function renderRelated(item, allPatches) {
const grid = document.querySelector('[data-related-grid]');
const heading = document.querySelector('[data-related-heading]');
// Work on a shuffled copy so repeat visits surface different picks
const pool = allPatches.slice();
for (let i = pool.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[pool[i], pool[j]] = [pool[j], pool[i]];
}
let related = pool.filter(p => p.Author === item.Author && p.Title !== item.Title).slice(0, 4);
let fromSameAuthor = related.length > 0;
if (related.length === 0) {
related = pool.filter(p => p.Title !== item.Title).slice(0, 4);
}
heading.textContent = fromSameAuthor && item.Author
? 'More from ' + item.Author
: 'More patches';
if (related.length === 0) {
grid.innerHTML = '<p style="grid-column: 1 / -1; color: hsl(var(--muted-foreground)); font-size: 0.875rem; text-align: center; padding: 2rem;">No other patches available yet.</p>';
return;
}
grid.innerHTML = related.map(p => `
<a class="store-item" href="${esc(itemHref(p.Title))}">
<div class="preview">
<img src="${esc(thumbUrl(p.StoreThumb))}" alt="" loading="lazy" />
</div>
<div class="body">
<div class="row">
<h3>${esc(p.Title)}</h3>
${p.Price ? `<span class="price">${esc(p.Price)}</span>` : ''}
</div>
${p.Author ? `<p class="author">By ${esc(p.Author)}</p>` : ''}
${p.Description ? `<p>${esc(p.Description)}</p>` : ''}
</div>
</a>
`).join('');
}
})();
</script>
</body>
</html>