58 lines
2.2 KiB
HTML
58 lines
2.2 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>
|
|
|
|
{{- else if eq $type "FAQPage" -}}
|
|
{{- $items := slice -}}
|
|
{{- range .Site.Data.faq -}}
|
|
{{- $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>
|
|
|
|
{{- else if eq $type "Article" -}}
|
|
{{- /* The About page is an editorial review, so we emit a Review with the
|
|
promoted operator as the reviewed item. */ -}}
|
|
{{- $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" "Organization" "name" $brand.name)
|
|
"publisher" (dict "@type" "Organization" "name" $brand.name "logo" (dict "@type" "ImageObject" "url" ($brand.logoPath | absURL)))
|
|
"itemReviewed" (dict "@type" "Organization" "name" $brand.legalOperatorName)
|
|
"reviewRating" (dict "@type" "Rating" "ratingValue" $brand.ratingValue "bestRating" 5 "worstRating" 1)
|
|
-}}
|
|
<script type="application/ld+json">{{ $data | jsonify | safeJS }}</script>
|
|
{{- end -}}
|