| 1 | {{- /* |
| 2 | Repo trend shortcode — inline bar chart for a numeric series. |
| 3 | |
| 4 | Usage (percent-brace shortcode call) with pipe-separated values: |
| 5 | repo-trend repo="cpaczek/skylight" values="120|340|512|890|2332" labels="W20|W21|W22|W23|W24" caption="Weekly star count." |
| 6 | */ -}} |
| 7 | {{- $values := slice -}} |
| 8 | {{- /* Coerce only well-formed numeric tokens; skip empty/non-numeric input so a |
| 9 | stray token (e.g. "N/A") never errors the build. */ -}} |
| 10 | {{- with .Get "values" }}{{ range (split . "|") }}{{ $t := trim . " " }}{{ if findRE `^-?[0-9]+(\.[0-9]+)?$` $t }}{{ $values = $values | append ($t | float) }}{{ end }}{{ end }}{{ end -}} |
| 11 | {{- $labels := slice -}} |
| 12 | {{- with .Get "labels" }}{{ $labels = split . "|" }}{{ end -}} |
| 13 | {{ partial "visuals/repo-trend.html" (dict |
| 14 | "values" $values |
| 15 | "labels" $labels |
| 16 | "repo" (.Get "repo") |
| 17 | "heading" (.Get "heading") |
| 18 | "level" (.Get "level") |
| 19 | "caption" (.Get "caption") |
| 20 | ) }} |