Skip to content

Commit 5af520d

Browse files
author
DavidQ
committed
Added prev/next back to the sample pages
1 parent 81f3489 commit 5af520d

3 files changed

Lines changed: 26 additions & 4 deletions

File tree

samples/shared/sampleDetailPageEnhancement.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,22 @@ function removePriorGeneratedBlocks(main) {
8383

8484
export function parseSampleFromPathname(pathname) {
8585
const text = String(pathname || '');
86-
const direct = text.match(/\/samples\/phase(\d{2})\/(\d{4})(?:\/index\.html)?\/?$/);
86+
const direct = text.match(/\/samples\/phase-?(\d{2})\/(\d{4})(?:\/index\.html)?\/?$/);
8787
if (direct) {
8888
return { phase: direct[1], id: direct[2] };
8989
}
9090

9191
const parts = text.split('/').filter(Boolean);
9292
for (let i = 0; i < parts.length - 1; i += 1) {
93-
if (/^phase\d{2}$/.test(parts[i]) && /^\d{4}$/.test(parts[i + 1])) {
94-
return { phase: parts[i].slice(5), id: parts[i + 1] };
93+
if (/^phase-?\d{2}$/i.test(parts[i]) && /^\d{4}$/.test(parts[i + 1])) {
94+
return { phase: parts[i].replace(/^phase-?/i, ''), id: parts[i + 1] };
9595
}
9696
}
9797
return null;
9898
}
9999

100100
export function canonicalSampleHref(sample) {
101-
return '/samples/phase' + sample.phase + '/' + sample.id + '/index.html';
101+
return '/samples/phase-' + sample.phase + '/' + sample.id + '/index.html';
102102
}
103103

104104
export function normalizeMetadata(raw) {

src/engine/theme/mount-shared-header.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,23 @@ const target = document.getElementById('shared-theme-header');
44
if (target) {
55
mountToolboxAidHeader(target);
66
}
7+
8+
async function mountSampleDetailEnhancementIfNeeded() {
9+
const path = String(window.location.pathname || '');
10+
const isSampleDetailRoute = /\/samples\/phase-?\d{2}\/\d{4}(?:\/index\.html)?\/?$/i.test(path);
11+
if (!isSampleDetailRoute) {
12+
return;
13+
}
14+
try {
15+
const module = await import('/samples/shared/sampleDetailPageEnhancement.js');
16+
if (typeof module.applySampleDetailEnhancement === 'function') {
17+
await module.applySampleDetailEnhancement();
18+
}
19+
} catch {
20+
// Non-fatal: sample page remains usable even if enhancement fails to load.
21+
}
22+
}
23+
24+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
25+
void mountSampleDetailEnhancementIfNeeded();
26+
}

tools/shared/platformShell.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
}
88

99
body.tools-platform-surface {
10+
min-height: 100vh;
11+
min-height: 100dvh;
1012
color: var(--text, #f7f4ff);
1113
background: var(--bg-gradient, linear-gradient(180deg, #c4b5fd 0%, #a78bfa 18%, #8b5cf6 36%, #7c3aed 54%, #6d28d9 74%, #5b21b6 88%, #4c1d95 100%));
1214
}

0 commit comments

Comments
 (0)