main
html 56 lines 2.48 KB
Raw
1 {{- /*
2 Signal & Noise summary module — a generated, scannable two-column card built
3 from structured frontmatter (or passed data). Surfaces the week's editorial
4 Signal/Noise framing without overstating: items are editorial judgments shown
5 as plain lists, with an explicit caveat slot. No automated ranking is implied.
6
7 Params (dict):
8 page : page context (used to read .Params.signal_noise if data omitted)
9 data : optional explicit dict {signal: [], noise: [], caveat: "", source: ""}
10 heading : optional heading text (default "Signal & Noise at a glance")
11 level : optional heading level (default "h2")
12 */ -}}
13 {{- $page := .page -}}
14 {{- $data := .data | default (and $page $page.Params.signal_noise) -}}
15 {{- $heading := .heading | default "Signal & Noise at a glance" -}}
16 {{- $level := .level | default "h2" | lower -}}
17 {{- if not (in (slice "h2" "h3" "h4" "h5" "h6") $level) }}{{ $level = "h2" }}{{ end -}}
18 {{- /* $level is strictly whitelisted above, so the tag name is safe to emit;
19 the heading text itself remains contextually auto-escaped. */ -}}
20 {{- $hOpen := printf `<%s class="signal-noise__heading">` $level | safeHTML -}}
21 {{- $hClose := printf "</%s>" $level | safeHTML -}}
22 {{- with $data -}}
23 {{- $signal := (index . "signal") | default slice -}}
24 {{- $noise := (index . "noise") | default slice -}}
25 {{- $caveat := (index . "caveat") | default "" -}}
26 {{- $source := (index . "source") | default "" -}}
27 {{- if or (gt (len $signal) 0) (gt (len $noise) 0) -}}
28 <section class="signal-noise" aria-label="{{ $heading }}">
29 {{ $hOpen }}{{ $heading }}{{ $hClose }}
30 <div class="signal-noise__cols">
31 {{- if gt (len $signal) 0 }}
32 <div class="signal-noise__col signal-noise__col--signal">
33 <p class="signal-noise__label">
34 <span class="signal-noise__dot" aria-hidden="true"></span>Durable signal
35 </p>
36 <ul class="signal-noise__list">
37 {{- range $signal }}<li>{{ . }}</li>{{ end }}
38 </ul>
39 </div>
40 {{- end }}
41 {{- if gt (len $noise) 0 }}
42 <div class="signal-noise__col signal-noise__col--noise">
43 <p class="signal-noise__label">
44 <span class="signal-noise__dot" aria-hidden="true"></span>Noise floor
45 </p>
46 <ul class="signal-noise__list">
47 {{- range $noise }}<li>{{ . }}</li>{{ end }}
48 </ul>
49 </div>
50 {{- end }}
51 </div>
52 {{- with $caveat }}<p class="signal-noise__caveat">{{ . }}</p>{{ end }}
53 {{- with $source }}<p class="signal-noise__source">{{ . }}</p>{{ end }}
54 </section>
55 {{- end -}}
56 {{- end -}}