@luhtech/site-template 0.14.4 → 0.14.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luhtech/site-template",
3
- "version": "0.14.4",
3
+ "version": "0.14.5",
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",
@@ -31,6 +31,7 @@
31
31
  // small external-link marker, the "nice links" treatment.
32
32
  import Diagram from './Diagram.astro';
33
33
  import Icon from './Icon.astro';
34
+ import { formatInlineMarkdown } from '../lib/formatInlineMarkdown';
34
35
 
35
36
  export interface Props {
36
37
  block: { blockType: string; text?: string; label?: string; href?: string; diagramId?: string; src?: string; alt?: string; caption?: string; name?: string; title?: string };
@@ -41,6 +42,11 @@ export interface Props {
41
42
  }
42
43
  const { block, diagrams = [], class: className = '' } = Astro.props;
43
44
  const items = block.blockType === 'list' ? (block.text ?? '').split('\n').filter(Boolean) : [];
45
+ // d-2026-09-16-sr-inline-markdown-rendering: every text-bearing block type
46
+ // gets real **bold**/_italic_/[link](url) rendering instead of literal
47
+ // markdown characters -- see formatInlineMarkdown's own doc comment for
48
+ // the real live bug this closes.
49
+ const text = block.text ? formatInlineMarkdown(block.text) : '';
44
50
  const isExternalLink = typeof block.href === 'string' && block.href.startsWith('https://');
45
51
  const Wrapper = block.href ? 'a' : Fragment;
46
52
  const wrapperProps = block.href
@@ -62,33 +68,33 @@ if (block.blockType === 'diagram') {
62
68
  {block.blockType === 'paragraph' && (
63
69
  <div class={className}>
64
70
  {block.label && <p class="font-display font-semibold text-accent-secondary mb-1">{block.label}</p>}
65
- <p class="leading-relaxed">{block.text}</p>
71
+ <p class="leading-relaxed" set:html={text} />
66
72
  </div>
67
73
  )}
68
- {block.blockType === 'lede' && <p class={`text-lg leading-relaxed ${className}`}>{block.text}</p>}
74
+ {block.blockType === 'lede' && <p class={`text-lg leading-relaxed ${className}`} set:html={text} />}
69
75
  {block.blockType === 'pullquote' && (
70
- <blockquote class={`border-l-4 border-accent-primary pl-4 italic text-lg ${className}`}>{block.text}</blockquote>
76
+ <blockquote class={`border-l-4 border-accent-primary pl-4 italic text-lg ${className}`} set:html={text} />
71
77
  )}
72
78
  {block.blockType === 'definition' && (
73
79
  <div class={className}>
74
80
  {block.label && <dt class="font-semibold">{block.label}</dt>}
75
- <dd class="leading-relaxed">{block.text}</dd>
81
+ <dd class="leading-relaxed" set:html={text} />
76
82
  </div>
77
83
  )}
78
- {block.blockType === 'caption' && <p class={`text-sm text-ink/60 ${className}`}>{block.text}</p>}
84
+ {block.blockType === 'caption' && <p class={`text-sm text-ink/60 ${className}`} set:html={text} />}
79
85
  {block.blockType === 'list' && (
80
86
  <div class={className}>
81
87
  {block.label && <p class="font-display font-semibold mb-1">{block.label}</p>}
82
88
  <ul class="list-disc list-inside space-y-1">
83
- {items.map((item) => <li>{item}</li>)}
89
+ {items.map((item) => <li set:html={formatInlineMarkdown(item)} />)}
84
90
  </ul>
85
91
  </div>
86
92
  )}
87
93
  {block.blockType === 'stat' && (
88
- <p class={`font-display text-xl font-semibold text-accent-primary bg-accent-primary/5 rounded-md px-4 py-3 ${className}`}>{block.text}</p>
94
+ <p class={`font-display text-xl font-semibold text-accent-primary bg-accent-primary/5 rounded-md px-4 py-3 ${className}`} set:html={text} />
89
95
  )}
90
96
  {block.blockType === 'close' && (
91
- <p class={`leading-relaxed border-t border-ink/10 pt-6 ${className}`}>{block.text}</p>
97
+ <p class={`leading-relaxed border-t border-ink/10 pt-6 ${className}`} set:html={text} />
92
98
  )}
93
99
  {block.blockType === 'diagram' && resolvedDiagram && <Diagram diagram={resolvedDiagram} class={`my-8 ${className}`} />}
94
100
  {block.blockType === 'image' && (
@@ -111,7 +117,7 @@ if (block.blockType === 'diagram') {
111
117
  {block.title && <p class="text-sm text-accent-secondary font-mono uppercase tracking-wide">{block.title}</p>}
112
118
  </div>
113
119
  </div>
114
- <p class="text-sm text-ink/80 leading-relaxed">{block.text}</p>
120
+ <p class="text-sm text-ink/80 leading-relaxed" set:html={text} />
115
121
  </div>
116
122
  )}
117
123
  {isExternalLink && (
@@ -62,8 +62,14 @@ export interface Props {
62
62
  toolSubmitEndpoint?: string;
63
63
  route?: string;
64
64
  ventureRef?: string;
65
+ // d-2026-09-16-bt-article-section-split: which heading level THIS
66
+ // article-kind section renders at -- a page can now carry several in
67
+ // sequence (one per real sub-heading the source article had), and only
68
+ // the first is the page's real H1. Same passthrough shape as the
69
+ // tool-related props above; every other sectionKind ignores it.
70
+ headingLevel?: 'h1' | 'h2';
65
71
  }
66
- const { section, site, companyLabel, icons, tool, toolSubmitEndpoint, route, ventureRef } = Astro.props;
72
+ const { section, site, companyLabel, icons, tool, toolSubmitEndpoint, route, ventureRef, headingLevel } = Astro.props;
67
73
  const Component = SECTION_COMPONENTS[section.sectionKind];
68
74
  if (!Component) {
69
75
  throw new Error(`Section.astro: unknown sectionKind "${section.sectionKind}" (id: ${section.sectionId})`);
@@ -72,7 +78,7 @@ if (!Component) {
72
78
  {section.sectionKind === 'cta' ? (
73
79
  <Cta section={section} leadCapture={site?.leadCapture} companyLabel={companyLabel} icons={icons} />
74
80
  ) : section.sectionKind === 'article' ? (
75
- <Component section={section} icons={icons} tool={tool} toolSubmitEndpoint={toolSubmitEndpoint} route={route} ventureRef={ventureRef} />
81
+ <Component section={section} icons={icons} tool={tool} toolSubmitEndpoint={toolSubmitEndpoint} route={route} ventureRef={ventureRef} headingLevel={headingLevel} />
76
82
  ) : (
77
83
  <Component section={section} icons={icons} />
78
84
  )}
@@ -30,18 +30,27 @@ export interface Props {
30
30
  toolSubmitEndpoint?: string;
31
31
  route?: string;
32
32
  ventureRef?: string;
33
+ // d-2026-09-16-bt-article-section-split: an article bridged onto a page
34
+ // now lands as MULTIPLE sectionKind:"article" entries (one per real
35
+ // ## heading the source article's ::section chunks carried, previously
36
+ // flattened into one giant section's blocks[] -- see venture_site.py's
37
+ // own history for why). Only the page's own title section is the real
38
+ // H1; every subsequent article section is a real H2 under it. Defaults
39
+ // to 'h1' so a genuinely single-section article page (or any other
40
+ // caller from before this split existed) renders exactly as before.
41
+ headingLevel?: 'h1' | 'h2';
33
42
  }
34
- const { section, tool, toolSubmitEndpoint, route, ventureRef } = Astro.props;
43
+ const { section, tool, toolSubmitEndpoint, route, ventureRef, headingLevel = 'h1' } = Astro.props;
35
44
  const referencedDiagramIds = new Set((section.blocks ?? []).filter((b: any) => b.blockType === 'diagram').map((b: any) => b.diagramId));
36
45
  const unreferencedDiagrams = (section.diagrams ?? []).filter((d: any) => !referencedDiagramIds.has(d.diagramId));
37
46
  ---
38
47
  <section id={section.sectionId} class="py-8" data-reveal>
39
48
  <SectionHeading
40
- level="h1"
49
+ level={headingLevel}
41
50
  eyebrow={section.eyebrow}
42
51
  heading={section.heading}
43
52
  subheading={section.subheading}
44
- headingClass="text-3xl sm:text-4xl"
53
+ headingClass={headingLevel === 'h1' ? 'text-3xl sm:text-4xl' : 'text-2xl sm:text-3xl'}
45
54
  subheadingClass="text-lg"
46
55
  class="mb-3 max-w-2xl"
47
56
  />
@@ -0,0 +1,47 @@
1
+ // d-2026-09-16-sr-inline-markdown-rendering. content/page.schema.json's own
2
+ // description has called block.text "markdown-safe" since it was first
3
+ // authored -- but nothing downstream ever actually parsed markdown out of
4
+ // it: Block.astro rendered `{block.text}` as a plain Astro/JSX text node
5
+ // (auto-escaped, never re-interpreted), on the assumption a consumer that
6
+ // wanted real markdown would "wrap this or replace it" (this file's own
7
+ // prior doc comment). No consumer ever did. Found live, 2026-09-16: every
8
+ // real bridged article carries real markdown in its body -- **bold**
9
+ // clauses, [text](url) links in a close block's CTA sentence -- authored
10
+ // straight through from the source article's own canonical markdown body,
11
+ // and it was rendering as literal asterisks and bracket-paren text on
12
+ // production pages (confirmed on luh.tech's real insight articles).
13
+ //
14
+ // This is a narrow, safe formatter -- not a markdown parser. It supports
15
+ // exactly the two constructs real content actually uses (bold, inline
16
+ // links) plus italic for symmetry with bold, and nothing else: no
17
+ // headings/lists/code/images (those are already their own real
18
+ // block.blockType values or diagram/image blocks, never markdown syntax
19
+ // inside a text block). Escapes the raw text FIRST, then only its own
20
+ // three regexes can introduce a tag -- safe for real authored content
21
+ // (not user input) without needing a full sanitizer dependency.
22
+ function escapeHtml(text: string): string {
23
+ return text
24
+ .replace(/&/g, '&amp;')
25
+ .replace(/</g, '&lt;')
26
+ .replace(/>/g, '&gt;')
27
+ .replace(/"/g, '&quot;');
28
+ }
29
+
30
+ // Same href shape page.schema.json's own cta.href pattern already allows
31
+ // (anchor, same-site path, or an https:// URL) -- a markdown link outside
32
+ // that shape is left as literal escaped text rather than becoming an
33
+ // unvetted href, matching this schema family's existing "mailto: is not
34
+ // permitted" discipline.
35
+ const SAFE_HREF = /^(#[a-z0-9-]+|\/[a-z0-9\-/]*|https:\/\/[^\s")]+)$/i;
36
+
37
+ export function formatInlineMarkdown(text: string): string {
38
+ let html = escapeHtml(text);
39
+ html = html.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (match, label: string, href: string) => {
40
+ if (!SAFE_HREF.test(href)) return match;
41
+ const external = href.startsWith('https://');
42
+ return `<a href="${href}" class="underline decoration-accent-primary/50 underline-offset-2 hover:decoration-accent-primary"${external ? ' target="_blank" rel="noopener noreferrer"' : ''}>${label}</a>`;
43
+ });
44
+ html = html.replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>');
45
+ html = html.replace(/(?<![a-zA-Z0-9])_([^_]+)_(?![a-zA-Z0-9])/g, '<em>$1</em>');
46
+ return html;
47
+ }