Skip to content

Commit f5a7445

Browse files
committed
fix(tour): parts rows now have real descriptions + section count as bonus
Part rows in the index Topics list previously showed only "N sections" as their one-liner — contextual but not descriptive. Topics rows had real summaries; parts were inconsistent. Changes: - tour.mts: pass partObjectives map (built from tour.json's per- part `objective` field) into rewriteIndexContents. Each part row now renders as: <title> / <objective> · <count> sections. Doc rows stay unchanged (they don't have section counts). - walkthrough-overrides.css: adds .wt-contents-bonus for the count annotation — one step lighter than --eyebrow so it reads as bonus metadata rather than part of the prose.
1 parent 034959b commit f5a7445

2 files changed

Lines changed: 45 additions & 22 deletions

File tree

scripts/tour.mts

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ async function renderDocs(
307307
async function rewriteIndexContents(
308308
partFilenames: ReadonlyMap<number, string>,
309309
partTitles: ReadonlyMap<number, string>,
310+
partObjectives: ReadonlyMap<number, string>,
310311
partCounts: ReadonlyMap<number, number>,
311312
docs: ReadonlyMap<string, DocEntry>,
312313
tourDir: string,
@@ -338,35 +339,40 @@ async function rewriteIndexContents(
338339

339340
// Build unified rows in stable order: parts 1..N first, then docs
340341
// in manifest order. Each row is a flat <div> carrying the same
341-
// shape — title link + muted context line. Using <div>s (not <ul>/
342-
// <li>) sidesteps the browser-default bullet rendering that made
343-
// the old list look off-tempo.
342+
// shape — title link + muted description. Parts also get a lighter
343+
// "N sections" bonus annotation appended inline. Using <div>s (not
344+
// <ul>/<li>) sidesteps the browser-default bullet rendering that
345+
// made the old list look off-tempo.
346+
const renderRow = (
347+
href: string,
348+
title: string,
349+
description: string,
350+
bonus?: string,
351+
): string => {
352+
const bonusHtml = bonus
353+
? ` <span class="wt-contents-bonus">· ${escapeHtml(bonus)}</span>`
354+
: ''
355+
return (
356+
` <div class="wt-contents-row">\n` +
357+
` <a class="wt-contents-title" href="${href}">${escapeHtml(title)}</a>\n` +
358+
(description
359+
? ` <p class="wt-contents-summary">${escapeHtml(description)}${bonusHtml}</p>\n`
360+
: '') +
361+
` </div>`
362+
)
363+
}
344364
const rows: string[] = []
345365
for (const [id, filename] of [...partFilenames.entries()].sort(
346366
(a, b) => a[0] - b[0],
347367
)) {
348368
const title = partTitles.get(id) ?? `Part ${id}`
369+
const description = partObjectives.get(id) ?? ''
349370
const count = partCounts.get(id)
350-
const context = count !== undefined ? `${count} sections` : ''
351-
rows.push(
352-
` <div class="wt-contents-row">\n` +
353-
` <a class="wt-contents-title" href="/${filename}.html">${escapeHtml(title)}</a>\n` +
354-
(context
355-
? ` <p class="wt-contents-summary">${context}</p>\n`
356-
: '') +
357-
` </div>`,
358-
)
371+
const bonus = count !== undefined ? `${count} sections` : undefined
372+
rows.push(renderRow(`/${filename}.html`, title, description, bonus))
359373
}
360374
for (const d of docs.values()) {
361-
const context = d.summary ?? ''
362-
rows.push(
363-
` <div class="wt-contents-row">\n` +
364-
` <a class="wt-contents-title" href="/${d.filename}.html">${escapeHtml(d.title)}</a>\n` +
365-
(context
366-
? ` <p class="wt-contents-summary">${escapeHtml(context)}</p>\n`
367-
: '') +
368-
` </div>`,
369-
)
375+
rows.push(renderRow(`/${d.filename}.html`, d.title, d.summary ?? ''))
370376
}
371377
const blockHtml =
372378
` <div class="wt-contents">\n` +
@@ -827,7 +833,12 @@ async function generate(
827833
? (JSON.parse(await fs.readFile(path.resolve(configPath), 'utf8')) as {
828834
slug?: string
829835
commentBackend?: string
830-
parts?: Array<{ id: number; title: string; filename?: string }>
836+
parts?: Array<{
837+
id: number
838+
title: string
839+
filename?: string
840+
objective?: string
841+
}>
831842
docs?: Array<{
832843
filename?: string | undefined
833844
title?: string | undefined
@@ -843,8 +854,12 @@ async function generate(
843854
// each pill as just "Part 1", "Part 2", …; with it, they get the
844855
// real section title ("Anatomy of a PURL" etc.).
845856
const partTitles = new Map<number, string>()
857+
const partObjectives = new Map<number, string>()
846858
for (const p of tourConfig.parts ?? []) {
847859
partTitles.set(p.id, p.title)
860+
if (p.objective) {
861+
partObjectives.set(p.id, p.objective)
862+
}
848863
}
849864

850865
// Map part-id → filename (e.g. 1 → "anatomy"). Drives both the flat
@@ -906,6 +921,7 @@ async function generate(
906921
await rewriteIndexContents(
907922
partFilenames,
908923
partTitles,
924+
partObjectives,
909925
partCounts,
910926
docFilenames,
911927
tourDir,

walkthrough-overrides.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,13 @@ html[data-theme='dark'] .file-grid > .code-section:hover {
356356
line-height: 1.45;
357357
color: var(--eyebrow);
358358
}
359+
.wt-contents-bonus {
360+
/* Section-count annotation — even lighter than the summary itself
361+
* so it reads as "bonus metadata" rather than part of the prose. */
362+
color: color-mix(in srgb, var(--eyebrow) 70%, transparent);
363+
font-variant-numeric: tabular-nums;
364+
margin-left: 2px;
365+
}
359366

360367
/* The first annotation inside each file-block is almost always file
361368
* boilerplate — license header, @fileoverview, etc. Render it in a

0 commit comments

Comments
 (0)