Merge pull request #2970 from chandlertee/fix/schema-author-data-authors

🐛 fix(schema): resolve article author from data/authors
This commit is contained in:
Nuno C. authored and GitHub committed 2026-07-02 12:36:20 +01:00
commit e8f44d4e8e
1 file changed
+19 -1
+19 -1
View File
@@ -17,6 +17,22 @@
</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",
@@ -29,7 +45,9 @@
"url" : {{ .Permalink }},
"author" : {
"@type": "Person",
"name": "{{ .Site.Params.Author.name | safeJS }}"
"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 }}