diff options
| author | Danilo M. <danix@danix.xyz> | 2026-11-05 17:16:56 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-11-05 17:16:56 +0100 |
| commit | afa0e5edda3c6d8097d7364a600e58eeded08938 (patch) | |
| tree | 20a6c093a4a0c0cee658ae816b011090dbc74454 /layouts/shortcodes | |
| parent | e4ed367a113801b025a16c870c29cb45a112e44b (diff) | |
| download | danixxyz-afa0e5edda3c6d8097d7364a600e58eeded08938.tar.gz danixxyz-afa0e5edda3c6d8097d7364a600e58eeded08938.zip | |
feat: show the latest HardenedPass release on its landing pagerelease_05112026-1717
Read from GitHub when the site builds, so visitors contact no third party and it
works without JavaScript. A failed lookup warns and leaves the line out.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'layouts/shortcodes')
| -rw-r--r-- | layouts/shortcodes/latest-release.html | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/layouts/shortcodes/latest-release.html b/layouts/shortcodes/latest-release.html new file mode 100644 index 0000000..33389c7 --- /dev/null +++ b/layouts/shortcodes/latest-release.html @@ -0,0 +1,16 @@ +{{- /* + The latest release of a GitHub repository, read when the site builds so visitors never contact + GitHub. Params: repo (owner/name), label. Prints nothing if GitHub cannot be reached. + The key changes on every build: GetRemote's cache never expires by default. + ponytail: each build leaves one small file in Hugo's cache; `hugo --gc` if that ever matters. +*/ -}} +{{- $url := printf "https://api.github.com/repos/%s/releases/latest" (.Get "repo") -}} +{{- with try (resources.GetRemote $url (dict "key" now.Unix)) -}} + {{- with .Err -}} + {{- warnf "latest-release: %s" . -}} + {{- else with .Value -}} + {{- with (. | transform.Unmarshal).tag_name -}} +<p class="cta-block__caption">{{ $.Get "label" }}: {{ strings.TrimPrefix "v" . }}</p> + {{- end -}} + {{- end -}} +{{- end -}} |
