feat : Add Structured data schema support for Issue #98

Signed-off-by: GitHub Action <action@github.com>
This commit is contained in:
GitHub Action
2024-11-01 15:36:24 +00:00
parent 7cdd07ccb1
commit f3100389c9
2 changed files with 70 additions and 0 deletions

View File

@ -9,6 +9,7 @@
{{ $author := (.Params.author | default .Site.Params.author.name) -}}<meta name="author" content="{{ $author }}">
{{- with .Page.Params.description | default .Site.Params.description -}}<meta name="description" content="{{.}}">{{- end -}}
{{- partial "structure-extra.html" . -}}
{{- partial "webschema.html" . -}}
<title>{{.Title}}</title>
{{ range .AlternativeOutputFormats -}}
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Title | safeHTML }}

View File

@ -0,0 +1,69 @@
{{- if .IsHome -}}
<script type="application/ld+json">
{
"@context" : "https://schema.org",
"@type" : "WebSite",
"name" : {{ site.Title }},
"description": {{ site.Params.description | plainify | truncate 180 | safeHTML }},
"logo": {{ site.Params.assets.favicon | default "favicon.ico" | absURL }},
"url" : {{ site.Home.Permalink }}
}
</script>
{{- else if .IsPage }}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BlogPosting",
"headline": {{ .Title | plainify}},
"name": "{{ .Title | plainify }}",
"description": {{ with .Description | plainify }}{{ . }}{{ else }}{{ .Summary | plainify }}{{ end -}},
"keywords": [
{{- if .Params.keywords -}}
{{ range $i, $e := .Params.keywords }}{{ if $i }}, {{ end }}{{ $e }}{{ end }}
{{- else -}}
{{ range $i, $e := .Params.tags }}{{ if $i }}, {{ end }}{{ $e }}{{ end }}
{{- end -}}
],
"articleBody": {{ .Content | safeJS | htmlUnescape | plainify }},
"wordCount" : "{{ .WordCount }}",
"inLanguage": {{ .Language.Lang | default "en-us" }},
{{ if .Params.featuredImg -}}
"image":{{ .Params.featuredImg | absURL }},
{{- else if .Params.images -}}
{{- with .Params.images -}}
{{- range first 1 . -}}
"image":{{. | absURL}},
{{- end -}}
{{- end }}
{{ end -}}
"datePublished": {{ .PublishDate }},
"dateModified": {{ .Lastmod }},
{{- if .Params.author }}
"author":{
"@type": "Person",
"name": {{ .Params.author }},
"url": {{ (ref . .Params.authorLink) | default (ref . .Site.Params.author.about) }}
}
{{ else }}
"author":{
"@type": "Person",
"name": {{ site.Params.author.name }},
"url": {{ ref . .Site.Params.author.about }}
}
{{ end -}}
"mainEntityOfPage": {
"@type": "WebPage",
"@id": {{ .Permalink | safeHTML }}
},
"publisher": {
"@type": "{{- ( site.Params.schema.publisherType | default "Organization") | title -}}",
"name": {{ site.Title }},
"description": {{ site.Params.description | plainify | truncate 180 | safeHTML }},
"logo": {
"@type": "ImageObject",
"url": {{ site.Params.assets.favicon | default "favicon.ico" | absURL }}
}
}
}
</script>
{{- end -}}