diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2023-02-25 13:15:44 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2023-02-25 13:15:44 +0100 |
| commit | 900bb5e845c3ad44defbd427cae3d44a4a43321f (patch) | |
| tree | df3d96a93771884add571e82336c29fc3d9c7a1c /code/frontpage/layouts/partials/head/structured-data.html | |
| download | greatoffice-900bb5e845c3ad44defbd427cae3d44a4a43321f.tar.xz greatoffice-900bb5e845c3ad44defbd427cae3d44a4a43321f.zip | |
feat: Initial commit
Diffstat (limited to 'code/frontpage/layouts/partials/head/structured-data.html')
| -rw-r--r-- | code/frontpage/layouts/partials/head/structured-data.html | 210 |
1 files changed, 210 insertions, 0 deletions
diff --git a/code/frontpage/layouts/partials/head/structured-data.html b/code/frontpage/layouts/partials/head/structured-data.html new file mode 100644 index 0000000..1f153a3 --- /dev/null +++ b/code/frontpage/layouts/partials/head/structured-data.html @@ -0,0 +1,210 @@ +{{ $baseURL := "/" | absURL -}} + +{{ $dot := . -}} +{{ $dot.Scratch.Set "path" "" -}} +{{ $dot.Scratch.Set "breadcrumb" slice -}} + +{{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" -}} +{{ $.Scratch.Add "path" .Site.BaseURL -}} + +{{ $.Scratch.Add "breadcrumb" (slice (dict "url" .Site.BaseURL "name" "home" "position" 1 )) -}} + {{ range $index, $element := split $url "/" -}} + {{ $dot.Scratch.Add "path" $element -}} + {{ $.Scratch.Add "path" "/" -}} + {{ if ne $element "" -}} + {{ $.Scratch.Add "breadcrumb" (slice (dict "url" ($.Scratch.Get "path") "name" . "position" (add $index 2))) -}} + {{ end -}} +{{ end -}} + +<script type="application/ld+json"> +{ + "@context": "https://schema.org", + "@graph": [ + { + {{ if eq .Site.Params.schemaType "Organization" -}} + "@type": "Organization", + "@id": {{ print $baseURL "#/schema/organization/1" }}, + {{ else -}} + "@type": "Person", + "@id": {{ print $baseURL "#/schema/person/1" }}, + {{ end -}} + "name": "{{ .Site.Params.schemaName }}", + "url": {{ print $baseURL }}, + "sameAs": [ + {{ with .Site.Params.schemaTwitter -}} + {{ . }} + {{ end -}} + {{ with .Site.Params.schemaLinkedIn -}} + , {{ . }} + {{ end -}} + {{ with .Site.Params.schemaGitHub -}} + , {{ . }} + {{ end -}} + ], + {{ if eq .Site.Params.schemaType "Organization" -}} + "logo": { + "@type": "ImageObject", + "@id": {{ print $baseURL "#/schema/image/1"}}, + "url": {{ print $baseURL .Site.Params.schemaLogo }}, + "width": {{ .Site.Params.schemaLogoWidth }}, + "height": {{ .Site.Params.schemaLogoHeight }}, + "caption": "{{ .Site.Params.schemaName }}" + }, + "image": { + "@id": {{ print $baseURL "#/schema/image/1" }} + } + {{ else -}} + "image": { + "@type": "ImageObject", + "@id": {{ print $baseURL "#/schema/image/1"}}, + "url": {{ print $baseURL .Site.Params.schemaImage }}, + "width": {{ .Site.Params.schemaImageWidth }}, + "height": {{ .Site.Params.schemaImageHeight }}, + "caption": "{{ .Site.Params.schemaName }}" + } + {{ end -}} + }, + { + "@type": "WebSite", + "@id": {{ print $baseURL "#/schema/website/1" }}, + "url": {{ print $baseURL }}, + "name": "{{ .Site.Params.title }}", + "description": "{{ .Site.Params.description }}", + {{ if eq .Site.Params.schemaType "Organization" -}} + "publisher": { + "@id": {{ print $baseURL "#/schema/organization/1" }} + } + {{ else -}} + "publisher": { + "@id": {{ print $baseURL "#/schema/person/1" }} + } + {{ end -}} + }, + { + {{ if and (ne .Kind "taxonomy") (ne .Kind "term") -}} + "@type": "WebPage", + {{ else -}} + "@type": "CollectionPage", + {{ end -}} + "@id": {{ .Permalink }}, + "url": {{ .Permalink }}, + "name": "{{ .Title }}", + "description": "{{ .Description }}", + "isPartOf": { + "@id": {{ print $baseURL "#/schema/website/1" }} + }, + {{ if eq .Site.Params.schemaType "Organization" -}} + "about": { + "@id": {{ print $baseURL "#/schema/organization/1" }} + }, + {{ else -}} + "about": { + "@id": {{ print $baseURL "#/schema/person/1" }} + }, + {{ end -}} + "datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05CET" }}", + "dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05CET" }}", + "breadcrumb": { + "@id": {{ print .Permalink "#/schema/breadcrumb/1" }} + }, + "primaryImageOfPage": { + "@id": {{ print .Permalink "#/schema/image/2" }} + }, + "inLanguage": "{{ .Site.Params.schemaLocale }}", + "potentialAction": [{ + "@type": "ReadAction", "target": [{{ .Permalink }}] + }] + }, + { + "@type": "BreadcrumbList", + "@id": {{ print .Permalink "#/schema/breadcrumb/1" }}, + "name": "Breadcrumbs", + "itemListElement": [{{ $list := $.Scratch.Get "breadcrumb" }}{{ $len := (len $list) }}{{ range $index, $element := $list }}{{ if ne .position 1 }},{{ end }}{ + "@type": "ListItem", + "position": {{ .position }}, + "item": { + {{ if ne (add $index 1) $len -}} + "@type": "WebPage", + "@id": {{ .url }}, + "url": {{ .url }}, + "name": "{{ .name | humanize | title }}" + {{ else -}} + "@id": {{ .url }} + {{ end -}} + } + }{{ end }}] + }, + + {{ if and (eq .Kind "page") (or (eq .Section "blog") (eq .Section "docs") (eq .Section "tutorial") (eq .Section "showcase")) -}} + { + "@context": "https://schema.org", + "@graph": [ + { + "@type": "Article", + "@id": {{ print $baseURL "#/schema/article/1" }}, + "headline": "{{ .Title }}", + "description": "{{ .Description }}", + "isPartOf": { + "@id": {{ .Permalink }} + }, + "mainEntityOfPage": { + "@id": {{ .Permalink }} + }, + "datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05CET" }}", + "dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05CET" }}", + "author": { + "@id": {{ print $baseURL "#/schema/person/2" }} + }, + {{ if eq .Site.Params.schemaType "Organization" -}} + "publisher": { + "@id": {{ print $baseURL "#/schema/organization/1" }} + }, + {{ else -}} + "publisher": { + "@id": {{ print $baseURL "#/schema/person/1" }} + }, + {{ end -}} + "image": { + "@id": {{ print .Permalink "#/schema/image/2" }} + } + } + ] + }, + { + "@context": "https://schema.org", + "@graph": [ + { + "@type": "Person", + "@id": {{ print $baseURL "#/schema/person/2" }}, + "name": {{ .Site.Params.schemaAuthor }}, + "sameAs": [ + {{ with .Site.Params.schemaAuthorTwitter -}} + {{ . }} + {{ end -}} + {{ with .Site.Params.schemaAuthorLinkedIn -}} + , {{ . }} + {{ end -}} + {{ with .Site.Params.schemaAuthorGitHub -}} + , {{ . }} + {{ end -}} + ] + } + ] + }, + {{ end -}} + { + "@context": "https://schema.org", + "@graph": [ + { + "@type": "ImageObject", + "@id": {{ print .Permalink "#/schema/image/2" }}, + "url": {{ $.Scratch.Get "primaryImage" }}, + "contentUrl": {{ $.Scratch.Get "primaryImage" }}, + "caption": "{{ .Title }}" + } + ] + } + + ] +} +</script>
\ No newline at end of file |
