Files
Nuno CoraçãoandClaude Fable 5 b05eff3b30 🐛 Fix i18n apostrophes in JS, schema author image, avatar crops
JSON-encode i18n strings injected into appearance.js (#3040), resolve
and publish the original author image for the JSON-LD schema (#3037),
and anchor avatar crops to Center so small and zoomed framings match
(#3016).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-17 20:19:02 +01:00

104 lines
3.8 KiB
HTML

{{ if .IsHome -}}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebSite",
"@id": {{ site.Home.Permalink | safeURL }},
"name": "{{ .Site.Title | safeJS }}",
{{ with .Site.Params.description }}"description": "{{ . | safeJS }}",{{ end }}
{{ with .Site.Language.Locale }}"inLanguage": "{{ . }}",{{ end }}
"url": {{ site.Home.Permalink | safeURL }},
{{ with .Site.Params.keywords }}"keywords": {{ . }},{{ end }}
"publisher" : {
"@type": "Person",
"name": "{{ .Site.Params.Author.name | safeJS }}"
}
}
</script>
{{ else }}
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
{{- /* Resolve the author: first `authors` front matter key looked up in data/authors/, else the site author. */ -}}
{{- $author := .Site.Params.Author -}}
{{- with .Params.authors -}}
{{- with index hugo.Data.authors (index . 0 | lower) -}}
{{- $author = . -}}
{{- end -}}
{{- end -}}
{{- /* sameAs from social profiles: data/authors uses `social`, the site author uses `links` (each a {platform: url} map). */ -}}
{{- $sameAs := slice -}}
{{- range (or $author.social $author.links) -}}
{{- range $platform, $url := . -}}
{{- if not (strings.HasPrefix $url "mailto:") -}}
{{- $sameAs = $sameAs | append $url -}}
{{- end -}}
{{- end -}}
{{- end -}}
<script type="application/ld+json">
[{
"@context": "https://schema.org",
"@type": "Article",
"articleSection": "{{ (site.GetPage .Section).Title | safeJS }}",
"name": "{{ .Title | safeJS }}",
"headline": "{{ .Title | safeJS }}",
{{ with .Description }}"description": "{{ . | safeJS }}",{{ end }}
{{ with .Site.Language.Locale }}"inLanguage": "{{ . }}",{{ end }}
"url" : {{ .Permalink }},
"author" : {
"@type": "Person",
"name": "{{ $author.name | safeJS }}"{{ with $author.image }},
{{- $authorImageURL := "" }}
{{- if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
{{- $authorImageURL = . }}
{{- else }}
{{- with resources.Get . }}
{{- /* Publish the original so the schema URL resolves even when
every other reference uses optimised variants. */}}
{{- $authorImageURL = .Permalink }}
{{- else }}
{{- $authorImageURL = . | absURL }}
{{- end }}
{{- end }}
"image": {{ $authorImageURL }}{{ end }}{{ if $sameAs }},
"sameAs": [{{ range $i, $u := $sameAs }}{{ if $i }}, {{ end }}{{ $u }}{{ end }}]{{ end }}
},
{{ with .PublishDate }}"copyrightYear": "{{ .Format "2006" }}",{{ end }}
{{ with .Date }}"dateCreated": "{{ .Format $iso8601 }}",{{ end }}
{{ with .PublishDate }}"datePublished": "{{ .Format $iso8601 }}",{{ end }}
{{ with .ExpiryDate }}"expires": "{{ .Format $iso8601 }}",{{ end }}
{{ with .Lastmod }}"dateModified": "{{ .Format $iso8601 }}",{{ end }}
{{ if .Keywords }}
{{ with .Keywords }}"keywords": {{ . }},{{ end }}
{{ else }}
{{ with .Params.tags }}"keywords": {{ . }},{{ end }}
{{ end }}
"mainEntityOfPage": {{ .Permalink }},
"wordCount": {{ .WordCount | int }}
}{{ if site.Params.enableStructuredBreadcrumbs | default false }},
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{{- $position := 0 -}}
{{- range .Ancestors -}}
{{- if not .IsHome -}}
{{- $position = add $position 1 -}}
{
"@type": "ListItem",
"position": {{ $position }},
"name": "{{ .Title }}",
"item": {{ .Permalink }}
},
{{- end -}}
{{- end -}}
{{- $position = add $position 1 -}}
{
"@type": "ListItem",
"position": {{ $position }},
"name": "{{ .Title }}",
"item": {{ .Permalink }}
}
]
}{{ end }}]
</script>
{{ end }}