mirror of
https://github.com/thegeeklab/hugo-geekblog.git
synced 2024-11-04 20:30:44 +00:00
86 lines
2.9 KiB
HTML
86 lines
2.9 KiB
HTML
{{ if .IsHome -}}
|
|
{{ $thumbnail := default (default "brand.svg" .Site.Params.logo) (index (default slice .Site.Params.images) 0) | absURL }}
|
|
<script type="application/ld+json">
|
|
{
|
|
"@context": "http://schema.org",
|
|
"@type": "WebSite",
|
|
{{ with .Site.Params.GeekblogAuthor -}}
|
|
{{ with index $.Site.Data.authors . }}"author": "{{ .name }}",{{ end }}
|
|
{{- end }}
|
|
"name": "{{ .Site.Title }}",
|
|
"url": "{{ .Site.BaseURL }}",
|
|
{{- with .Site.Params.description }}
|
|
"description": "{{ . }}",
|
|
{{- end }}
|
|
"thumbnailUrl": "{{ $thumbnail }}"
|
|
{{- with .Site.Params.GeekblogContentLicense }},
|
|
"license": "{{ .name }}"
|
|
{{- end }}
|
|
}
|
|
</script>
|
|
{{ else if .IsPage }}
|
|
{{ $authors := default (slice .Site.Params.GeekblogAuthor) .Params.authors }}
|
|
{{ $description := default .Site.Params.description (default .Description .Summary) }}
|
|
{{ $ac := 0 }}
|
|
{{ $ac_max := default 0 (len $authors) }}
|
|
<script type="application/ld+json">
|
|
{
|
|
"@context": "http://schema.org",
|
|
"@type": "BlogPosting",
|
|
"articleSection": "{{ .Section }}",
|
|
"name": "{{ .Title | safeJS }}",
|
|
"headline": "{{ .Title | safeJS }}",
|
|
"alternativeHeadline": "{{ .Params.lead }}",
|
|
{{- with $description }}
|
|
"description": "{{ . }}",
|
|
{{- end }}
|
|
"inLanguage": {{ .Site.Language.Lang }},
|
|
"isFamilyFriendly": "true",
|
|
"mainEntityOfPage": {
|
|
"@type": "WebPage",
|
|
"@id": "{{ .Permalink }}"
|
|
},
|
|
{{- with $authors }}
|
|
"author" : [
|
|
{{- range sort . }}
|
|
{{- with . -}}
|
|
{{- $ac = (add $ac 1) }}
|
|
{{- $author := index $.Site.Data.authors . }}
|
|
{
|
|
"@type": "Person",
|
|
"name": "{{ $author.name }}"
|
|
}{{ if lt $ac $ac_max }},{{ end }}
|
|
{{- end -}}
|
|
{{- end }}
|
|
],
|
|
{{- end }}
|
|
"copyrightHolder" : "{{ .Site.Title }}",
|
|
"copyrightYear" : "{{ .Date.Format "2006" }}",
|
|
"dateCreated": "{{ .Date.Format "2006-01-02T15:04:05.00Z" | safeJS }}",
|
|
"datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05.00Z" | safeJS }}",
|
|
"dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05.00Z" | safeJS }}",
|
|
"publisher":{
|
|
"@type":"Organization",
|
|
"name": {{ .Site.Title }},
|
|
"url": {{ .Site.BaseURL }},
|
|
"logo": {
|
|
"@type": "ImageObject",
|
|
"url": "{{ (default "brand.svg" .Site.Params.logo) | absURL }}",
|
|
"width":"32",
|
|
"height":"32"
|
|
}
|
|
},
|
|
{{- with $images := $.Resources.ByType "image" }}
|
|
"image": [ {{ range $i, $image := $images }}{{ if $i }}, {{ end }}"{{ $image.Permalink | absURL }}" {{ end }}],
|
|
{{- else }}
|
|
{{- with $images := .Params.images }}
|
|
"image": [ {{ range $i, $image := $images }}{{ if $i }}, {{ end }}"{{ $image | absURL }}" {{ end }}],
|
|
{{- end }}
|
|
{{- end }}
|
|
"url" : "{{ .Permalink }}",
|
|
"wordCount" : "{{ .WordCount }}",
|
|
"genre" : [ {{ range $i, $tag := .Params.tags }}{{ if $i }}, {{ end }}"{{ $tag }}" {{ end }}]
|
|
}
|
|
</script>
|
|
{{ end }}
|