Skip to content

Commit 85337bc

Browse files
authored
Merge pull request #3 from HTMLTrust/fix/signed-section-badge-anchoring
fix: anchor extension badges inside signed-section, not the viewport
2 parents f70c535 + 65957ee commit 85337bc

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{{- /*
2+
htmltrust-signed-section.html — wraps .Content in a <signed-section> placeholder.
3+
4+
Spec-conformant cryptographic signing (content-hash + signature) is NOT performed
5+
in this template. Hugo cannot do NFKC normalization or Ed25519 signing. This
6+
partial emits a structural placeholder; the companion `htmltrust-sign` CLI fills
7+
in the four required attributes (content-hash, signature, keyid, algorithm)
8+
after `hugo build`.
9+
10+
Opt in per-page via frontmatter:
11+
12+
htmltrust:
13+
sign: true
14+
claims:
15+
ContentType: "Article"
16+
License: "CC-BY-4.0"
17+
18+
Site-level defaults (config.toml):
19+
20+
[params.htmltrust]
21+
keyid = "did:web:example.com"
22+
algorithm = "ed25519"
23+
*/ -}}
24+
{{- if and .Params.htmltrust .Params.htmltrust.sign -}}
25+
{{- $st := .Site.Params.htmltrust | default dict -}}
26+
{{- $keyid := .Params.htmltrust.keyid | default $st.keyid | default "" -}}
27+
{{- $algo := .Params.htmltrust.algorithm | default $st.algorithm | default "ed25519" -}}
28+
{{- $author := .Params.author | default .Site.Params.author | default "" -}}
29+
{{- $signedAt := "" -}}
30+
{{- if not .Date.IsZero -}}
31+
{{- $signedAt = .Date.Format "2006-01-02T15:04:05Z07:00" -}}
32+
{{- end -}}
33+
<signed-section content-hash="" signature="" keyid="{{ $keyid }}" algorithm="{{ $algo }}" data-htmltrust-placeholder="true" style="display: block; position: relative;">
34+
{{- with $author }}
35+
<meta name="author" content="{{ . }}">
36+
{{- end }}
37+
{{- with $signedAt }}
38+
<meta name="signed-at" content="{{ . }}">
39+
{{- end }}
40+
{{- with .Params.htmltrust.claims }}
41+
{{- range $key, $value := . }}
42+
<meta name="claim:{{ $key }}" content="{{ $value }}">
43+
{{- end }}
44+
{{- end }}
45+
{{ .Content }}
46+
</signed-section>
47+
{{- else -}}
48+
{{ .Content }}
49+
{{- end -}}

0 commit comments

Comments
 (0)