mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-10-10 22:09:31 +00:00
schema.html always read the author from .Site.Params.Author, so the structured-data author was the site-level author (or empty) regardless of a post's `authors` front matter — even though the theme supports multiple authors via data/authors/. Resolve the first `authors` key against data/authors/ and emit that author's name, image and sameAs (from their social/links), falling back to the site-level author. Single-author output is unchanged apart from the additive image and sameAs fields. Fixes #2943 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
92 lines
3.3 KiB
HTML
92 lines
3.3 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 site.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 }},
|
|
"image": {{ . | absURL }}{{ 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": "true",
|
|
"wordCount": "{{ .WordCount }}"
|
|
}{{ 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 }}
|