@brandon_m_behring/book-scaffold-astro 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,14 +6,17 @@
6
6
  * tools), so this component renders only the fields that are present on
7
7
  * the chapter data. Tools-profile metadata (volatility, last_verified,
8
8
  * tools_compared) appears when defined; academic-profile metadata (week,
9
- * status) appears in its place.
9
+ * part, status, companion artifacts) appears in its place.
10
10
  *
11
- * Use a chapter card's metadata to calibrate how much trust to place in
12
- * its specific claims stable principles age slowly; feature surfaces
13
- * age fast.
11
+ * v3.1.0 academic flavor: Roman-numeral part labels, StatusBadge
12
+ * component, and an optional companion-artifacts block matching v2.0's
13
+ * hand-rolled academic ChapterHeader (verbatim restore for content density
14
+ * parity at narrow viewports).
14
15
  */
15
16
  import type { CollectionEntry } from 'astro:content';
16
17
  import { getFreshness, freshnessLabel } from '../src/lib/freshness';
18
+ import StatusBadge from './StatusBadge.astro';
19
+ import CodeRef from './CodeRef.astro';
17
20
 
18
21
  interface Props {
19
22
  data: CollectionEntry<'chapters'>['data'];
@@ -51,9 +54,24 @@ const freshnessText = freshness
51
54
  : 'Stale'
52
55
  : null;
53
56
 
57
+ // Academic-profile part labels (Roman-numeral · descriptive name).
58
+ // v2.0 post_transformers used this exact mapping; verbatim restore here so
59
+ // the header content density matches at narrow viewports. Keys mirror
60
+ // `academicParts` enum from src/schemas.ts.
61
+ const ACADEMIC_PART_LABELS: Record<string, string> = {
62
+ foundations: 'Part I · Foundations',
63
+ 'ssm-core': 'Part II · SSM Core',
64
+ 'beyond-ssm': 'Part III · Beyond SSMs',
65
+ integration: 'Part IV · Integration',
66
+ synthesis: 'Part V · Synthesis',
67
+ };
68
+
54
69
  // Display strings, profile-tagged for clarity in markup.
55
70
  const partLabel = (() => {
56
71
  const p = d.part;
72
+ if (hasAcademicMeta && typeof p === 'string' && p in ACADEMIC_PART_LABELS) {
73
+ return ACADEMIC_PART_LABELS[p];
74
+ }
57
75
  if (typeof p === 'number') return `Part ${p}`;
58
76
  if (typeof p === 'string' && p.length > 0) return `Part: ${p}`;
59
77
  return null;
@@ -61,8 +79,6 @@ const partLabel = (() => {
61
79
  const chapterNum =
62
80
  typeof d.chapter === 'number' ? `Chapter ${d.chapter}` : null;
63
81
  const weekNum = typeof d.week === 'number' ? `Week ${d.week}` : null;
64
- const statusBadge =
65
- typeof d.status === 'string' ? d.status.replace(/_/g, ' ') : null;
66
82
  const title = typeof d.title === 'string' ? d.title : '(untitled)';
67
83
  const description = typeof d.description === 'string' ? d.description : null;
68
84
  const toolsCompared = Array.isArray(d.tools_compared)
@@ -71,16 +87,30 @@ const toolsCompared = Array.isArray(d.tools_compared)
71
87
  const lastVerified = d.last_verified instanceof Date ? d.last_verified : null;
72
88
  const updated = d.updated instanceof Date ? d.updated : null;
73
89
  const volatility = typeof d.volatility === 'string' ? d.volatility : null;
90
+
91
+ // Academic companion artifacts. Notebook source path is transformed via
92
+ // generic basename strip so any book whose render-notebooks output lands
93
+ // under public/notebooks/ gets a correct deep link (v2.0 hardcoded a
94
+ // post_transformers-specific prefix; v3.1.0 generalizes).
95
+ const hasCompanions =
96
+ hasAcademicMeta &&
97
+ (typeof d.code_path === 'string' ||
98
+ typeof d.tests_path === 'string' ||
99
+ typeof d.notebook_path === 'string');
100
+ const notebookHtmlPath =
101
+ typeof d.notebook_path === 'string'
102
+ ? `/notebooks/${(d.notebook_path as string)
103
+ .replace(/^.*\//, '')
104
+ .replace(/\.ipynb$/, '')}.html`
105
+ : null;
74
106
  ---
75
107
  <header class="chapter-header">
76
108
  <div class="chapter-meta">
77
- {partLabel && <span>{partLabel}</span>}
109
+ {partLabel && <span class="chapter-part">{partLabel}</span>}
78
110
  {chapterNum && <span>{chapterNum}</span>}
79
- {weekNum && <span>{weekNum}</span>}
80
- {statusBadge && (
81
- <span class="status-badge" data-status={d.status as string}>
82
- {statusBadge}
83
- </span>
111
+ {weekNum && <span class="chapter-week">{weekNum}</span>}
112
+ {hasAcademicMeta && typeof d.status === 'string' && (
113
+ <StatusBadge status={d.status as never} />
84
114
  )}
85
115
  {lastVerified && (
86
116
  <span>
@@ -99,6 +129,30 @@ const volatility = typeof d.volatility === 'string' ? d.volatility : null;
99
129
  </div>
100
130
  <h1>{title}</h1>
101
131
  {description && <p class="chapter-description">{description}</p>}
132
+
133
+ {hasCompanions && (
134
+ <aside class="chapter-companions">
135
+ <strong>Companion artifacts:</strong>
136
+ <ul>
137
+ {typeof d.code_path === 'string' && (
138
+ <li>
139
+ Implementation: <CodeRef path={d.code_path as string} />
140
+ </li>
141
+ )}
142
+ {typeof d.tests_path === 'string' && (
143
+ <li>
144
+ Tests: <CodeRef path={d.tests_path as string} />
145
+ </li>
146
+ )}
147
+ {notebookHtmlPath && (
148
+ <li>
149
+ Notebook: <a href={notebookHtmlPath}>{notebookHtmlPath}</a>
150
+ </li>
151
+ )}
152
+ </ul>
153
+ </aside>
154
+ )}
155
+
102
156
  {hasToolsMeta && volatility && (
103
157
  <div class="chapter-badge-row">
104
158
  <span class="chapter-badge-row-label">Volatility:</span>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@brandon_m_behring/book-scaffold-astro",
3
3
  "description": "Astro 6 + MDX toolkit for long-form technical books. Profile-aware (academic / tools / minimal); ships Tufte typography, KaTeX, BibTeX citations, Pagefind, Cloudflare Workers deploy. See PACKAGE_DESIGN.md for the API contract.",
4
- "version": "3.0.1",
4
+ "version": "3.1.0",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "Brandon Behring",