Files
hugo_blog.awin.one/layouts/partials/components/schema-page.html
2022-05-10 01:13:38 +08:00

62 lines
1.9 KiB
HTML

<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Article",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": {{ .Permalink }}
},
"headline": "{{ partial "get-title" . }}",
{{- $img := partial "utils/get-image" (dict "context" . "url" .Params.featuredImage "keyword" "*featured*") }}
{{- with $img }}
"image": {{ . }},
{{ end -}}
{{ if .IsPage -}}
{{ if not .PublishDate.IsZero -}}
"datePublished": {{ .PublishDate.Format "2006-01-02T15:04:05-07:00" }},
{{ else if not .Date.IsZero -}}
"datePublished": {{ .Date.Format "2006-01-02T15:04:05-07:00" }},
{{ end -}}
{{ if not .Lastmod.IsZero -}}
"dateModified": {{ .Lastmod.Format "2006-01-02T15:04:05-07:00" }},
{{ end -}}
{{ end -}}
{{ with .WordCount -}}
"wordCount": {{ . }},
{{ end -}}
{{ with .Params.authors -}}
"author": {
"@type": "Person",
"name": {{ . }}
},
{{ end -}}
"publisher": {
{{ with .Site.Params.siteType -}}
"@type": {{ . }},
{{ else -}}
"@type": "Person",
{{ end -}}
{{ with .Site.Params.publisherName -}}
"name": {{ . }},
{{ else -}}
"name": {{ .Site.Title }},
{{ end -}}
{{ $publisherLogo := partial "utils/get-image" (dict "context" . "url" .Site.Params.publisherLogo) -}}
{{ $icon := partial "utils/get-image" (dict "context" . "url" .Site.Params.icon) -}}
{{ if $publisherLogo -}}
"logo": {
"@type": "ImageObject",
"url": {{ $publisherLogo }}
}
{{ else if $icon -}}
"logo": {
"@type": "ImageObject",
"url": {{ $icon }}
}
{{ end -}}
},
"description": "{{ if .Description }}{{ .Description }}{{ else if .Summary }}{{ .Summary }}{{ else if .Site.Params.Description }}{{ .Site.Params.Description }}{{ end }}"
}
</script>