77 lines
3.0 KiB
HTML
77 lines
3.0 KiB
HTML
{{- /* schema-jsonld.html — emits JSON-LD based on the page's front-matter
|
|
schemaType. BreadcrumbList is emitted separately by breadcrumbs.html.
|
|
Uses dict + jsonify so all values are safely escaped. */ -}}
|
|
{{- $brand := .Site.Data.brand -}}
|
|
{{- $type := .Params.schemaType | default "none" -}}
|
|
|
|
{{- if eq $type "Organization" -}}
|
|
{{- $sameAs := slice -}}
|
|
{{- range $brand.socialLinks -}}
|
|
{{- $sameAs = $sameAs | append .url -}}
|
|
{{- end -}}
|
|
{{- $data := dict
|
|
"@context" "https://schema.org"
|
|
"@type" "Organization"
|
|
"name" $brand.name
|
|
"url" .Site.BaseURL
|
|
"logo" ($brand.logoPath | absURL)
|
|
"description" $brand.tagline
|
|
"email" $brand.contactEmail
|
|
"foundingDate" (printf "%d" (int $brand.foundedYear))
|
|
"sameAs" $sameAs
|
|
-}}
|
|
<script type="application/ld+json">{{ $data | jsonify | safeJS }}</script>
|
|
|
|
{{- end -}}
|
|
|
|
{{- if or .IsHome (eq $type "FAQPage") .Params.showFaqAccordion -}}
|
|
{{- $faqKey := printf "faq.%s" .Language.Lang -}}
|
|
{{- $faqs := index .Site.Data $faqKey -}}
|
|
{{- if not $faqs -}}{{- $faqs = .Site.Data.faq -}}{{- end -}}
|
|
{{- $items := slice -}}
|
|
{{- range $faqs -}}
|
|
{{- $items = $items | append (dict
|
|
"@type" "Question"
|
|
"name" .question
|
|
"acceptedAnswer" (dict "@type" "Answer" "text" .answer)
|
|
) -}}
|
|
{{- end -}}
|
|
{{- $data := dict
|
|
"@context" "https://schema.org"
|
|
"@type" "FAQPage"
|
|
"mainEntity" $items
|
|
-}}
|
|
<script type="application/ld+json">{{ $data | jsonify | safeJS }}</script>
|
|
|
|
{{- end -}}
|
|
|
|
{{- if and (eq $type "Article") .Params.showRatingWidget -}}
|
|
{{- $authorName := .Params.authorName | default $brand.name -}}
|
|
{{- $authorType := cond (isset .Params "authorName") "Person" "Organization" -}}
|
|
{{- $data := dict
|
|
"@context" "https://schema.org"
|
|
"@type" "Review"
|
|
"headline" (.Params.h1 | default .Title)
|
|
"url" .Permalink
|
|
"datePublished" (.Date.Format "2006-01-02")
|
|
"dateModified" (.Lastmod.Format "2006-01-02")
|
|
"author" (dict "@type" $authorType "name" $authorName)
|
|
"publisher" (dict "@type" "Organization" "name" $brand.name "logo" (dict "@type" "ImageObject" "url" ($brand.logoPath | absURL)))
|
|
"itemReviewed" (dict "@type" "Organization" "name" $brand.name)
|
|
"reviewRating" (dict "@type" "Rating" "ratingValue" (.Params.rating | default $brand.ratingValue) "bestRating" 5 "worstRating" 1)
|
|
-}}
|
|
<script type="application/ld+json">{{ $data | jsonify | safeJS }}</script>
|
|
{{- else if eq $type "Article" -}}
|
|
{{- $data := dict
|
|
"@context" "https://schema.org"
|
|
"@type" "Article"
|
|
"headline" (.Params.h1 | default .Title)
|
|
"url" .Permalink
|
|
"datePublished" (.Date.Format "2006-01-02")
|
|
"dateModified" (.Lastmod.Format "2006-01-02")
|
|
"author" (dict "@type" "Organization" "name" $brand.name)
|
|
"publisher" (dict "@type" "Organization" "name" $brand.name "logo" (dict "@type" "ImageObject" "url" ($brand.logoPath | absURL)))
|
|
-}}
|
|
<script type="application/ld+json">{{ $data | jsonify | safeJS }}</script>
|
|
{{- end -}}
|