@luhtech/site-template 0.18.1 → 0.19.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.
@@ -60,7 +60,8 @@ function main() {
60
60
  }
61
61
 
62
62
  const entries = found
63
- .map((f) => ` ${f.id}: ${JSON.stringify({ name: f.name, oneLiner: f.oneLiner })},`)
63
+ // an id that is not a plain identifier (luhtech-business) must be a quoted key
64
+ .map((f) => ` ${/^[A-Za-z_$][\w$]*$/.test(f.id) ? f.id : JSON.stringify(f.id)}: ${JSON.stringify({ name: f.name, oneLiner: f.oneLiner })},`)
64
65
  .join('\n');
65
66
 
66
67
  const output = `// GENERATED by bin/luhtech-sync-venture-directory.mjs -- DO NOT HAND-EDIT.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luhtech/site-template",
3
- "version": "0.18.1",
3
+ "version": "0.19.0",
4
4
  "description": "Shared Astro component library + content-instance contract for LuhTech venture marketing sites -- one template renders every site from content/page.schema.json + content/site.schema.json instances.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -46,6 +46,7 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@lucide/astro": "^1.42.0",
49
- "@resvg/resvg-js": "^2.6.2"
49
+ "@resvg/resvg-js": "^2.6.2",
50
+ "@luhtech/figures": "^0.1.0"
50
51
  }
51
52
  }
@@ -37,7 +37,7 @@ export interface Props {
37
37
  block: { blockType: string; text?: string; label?: string; href?: string; diagramId?: string; src?: string; alt?: string; caption?: string; name?: string; title?: string };
38
38
  // This section's own diagrams[] array, only needed when block.blockType
39
39
  // is "diagram" -- the block is a position, diagrams[] stays the data.
40
- diagrams?: { diagramId: string; diagramType: string; caption?: string; data: any }[];
40
+ diagrams?: { diagramId: string; diagramType?: string; caption?: string; data?: any; figureRef?: string }[];
41
41
  class?: string;
42
42
  }
43
43
  const { block, diagrams = [], class: className = '' } = Astro.props;
@@ -7,13 +7,20 @@ import RingComparison from './diagrams/RingComparison.astro';
7
7
  import VectorSum from './diagrams/VectorSum.astro';
8
8
  import DataLineChart from './diagrams/DataLineChart.astro';
9
9
  import ConnectionGraph from './diagrams/ConnectionGraph.astro';
10
+ import Figure from '@luhtech/figures/astro';
11
+ import { figureFor } from '../content/figures.js';
10
12
 
11
13
  export interface Props {
12
- diagram: { diagramId: string; diagramType: string; caption?: string; data: any };
14
+ // d-2026-10-16-bt-figure-kit (page 2.8.0): a diagram either draws inline (diagramType + data) or
15
+ // names a figure record by figureRef, drawn by @luhtech/figures in the site's brand theme.
16
+ diagram: { diagramId: string; diagramType?: string; caption?: string; data?: any; figureRef?: string };
13
17
  class?: string;
14
18
  }
15
19
  const { diagram, class: className = 'my-8' } = Astro.props;
20
+ const named = diagram.figureRef ? figureFor(diagram.figureRef) : null;
16
21
  ---
22
+ {named && <Figure figure={named.record} theme={named.theme} class={className} />}
23
+ {!named && (
17
24
  <figure class={className}>
18
25
  {diagram.diagramType === 'ring-comparison' && <RingComparison rings={diagram.data.rings} />}
19
26
  {diagram.diagramType === 'vector-sum' && <VectorSum rays={diagram.data.rays} />}
@@ -25,3 +32,4 @@ const { diagram, class: className = 'my-8' } = Astro.props;
25
32
  )}
26
33
  {diagram.caption && <figcaption class="text-sm text-ink/60 mt-2 text-center">{diagram.caption}</figcaption>}
27
34
  </figure>
35
+ )}
@@ -0,0 +1,42 @@
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+
4
+ /**
5
+ * Figure records (schema-registry content/figure) for a page's figureRef diagrams
6
+ * (d-2026-10-16-bt-figure-kit). A site loads its records and builds its brand's theme once, then
7
+ * every diagram that names a figure draws it with @luhtech/figures -- the same SVG the dashboard,
8
+ * a room or a still draws from the same record. Records and the theme are site-wide (one brand per
9
+ * site), so one registry per build is the right scope.
10
+ */
11
+ export interface FigureConfig {
12
+ /** figureId -> figure record */
13
+ records: Record<string, any>;
14
+ /** a @luhtech/figures Theme, from buildTheme(brand) */
15
+ theme: any;
16
+ }
17
+
18
+ let config: FigureConfig | null = null;
19
+
20
+ /** Reads every content/figure instance in `dir`, keyed by figureId. A missing dir is no figures. */
21
+ export function loadFigures(dir: string): Record<string, any> {
22
+ if (!existsSync(dir)) return {};
23
+ const out: Record<string, any> = {};
24
+ for (const f of readdirSync(dir).filter((n) => n.endsWith('.json')).sort()) {
25
+ const rec = JSON.parse(readFileSync(join(dir, f), 'utf-8'));
26
+ if (out[rec.figureId]) throw new Error(`figureId ${rec.figureId} appears twice in ${dir}`);
27
+ out[rec.figureId] = rec;
28
+ }
29
+ return out;
30
+ }
31
+
32
+ export function configureFigures(c: FigureConfig): void {
33
+ config = c;
34
+ }
35
+
36
+ /** The record and theme a figureRef draws with; a dangling reference is an authoring error. */
37
+ export function figureFor(ref: string): { record: any; theme: any } {
38
+ if (!config) throw new Error(`diagram names figure ${ref}, but this site has not called configureFigures()`);
39
+ const record = config.records[ref];
40
+ if (!record) throw new Error(`diagram names figure ${ref}, which is not among this site's figure records`);
41
+ return { record, theme: config.theme };
42
+ }
@@ -7,3 +7,5 @@ export type { LoadedBrand } from './loadBrand.js';
7
7
  export { applyBrandDefaults } from './bindBrand.js';
8
8
  export { loadTool } from './loadTool.js';
9
9
  export type { LoadedTool, ToolFieldSpec, ToolPresentationSpec, ToolMethodNoteSpec, ToolSourceSpec } from './loadTool.js';
10
+ export { loadFigures, configureFigures, figureFor } from './figures.js';
11
+ export type { FigureConfig } from './figures.js';
@@ -18,5 +18,5 @@ export const VENTURE_DIRECTORY: Record<string, VentureDirectoryEntry> = {
18
18
  raizal: {"name":"Raizal","oneLiner":"A cooperative carbon marketplace with credits traced to the field."},
19
19
  replique: {"name":"Replique","oneLiner":"Protocol intelligence for the research bench."},
20
20
  hilja: {"name":"Hilja","oneLiner":"Intelligent surfaces that tune a room to how it's being used."},
21
- luhtech-business: {"name":"LuhTech","oneLiner":"A construction technology venture studio."},
21
+ "luhtech-business": {"name":"LuhTech","oneLiner":"A construction technology venture studio."},
22
22
  };