43 lines
1.6 KiB
HTML
43 lines
1.6 KiB
HTML
|
|
{{- if .IsHome -}}
|
||
|
|
{{- $schema := dict
|
||
|
|
"@context" "https://schema.org"
|
||
|
|
"@type" "WebSite"
|
||
|
|
"name" .Site.Title
|
||
|
|
"url" .Site.BaseURL
|
||
|
|
"description" .Site.Params.description
|
||
|
|
"publisher" (dict "@type" "Organization" "name" .Site.Title "url" .Site.BaseURL)
|
||
|
|
"potentialAction" (dict
|
||
|
|
"@type" "SearchAction"
|
||
|
|
"target" (dict "@type" "EntryPoint" "urlTemplate" (print .Site.BaseURL "recipes/?q={search_term_string}"))
|
||
|
|
"query-input" "required name=search_term_string"
|
||
|
|
)
|
||
|
|
-}}
|
||
|
|
{{- printf "<script type=\"application/ld+json\">%s</script>" ($schema | jsonify) | safeHTML -}}
|
||
|
|
{{- else if and .IsPage (eq .Section "recipes") -}}
|
||
|
|
{{- $img := "" -}}
|
||
|
|
{{- with .Resources.GetMatch "cocktail.*" -}}
|
||
|
|
{{- $img = (.Resize "800x webp").Permalink | absURL -}}
|
||
|
|
{{- else -}}
|
||
|
|
{{- $img = .Params.drinkThumbnail | default (.Site.Params.ogImage | absURL) -}}
|
||
|
|
{{- end -}}
|
||
|
|
|
||
|
|
{{- $category := "" -}}
|
||
|
|
{{- with .Params.categories -}}{{- $category = index . 0 -}}{{- end -}}
|
||
|
|
|
||
|
|
{{- $description := .Description | default .Site.Params.description -}}
|
||
|
|
|
||
|
|
{{- $schema := dict
|
||
|
|
"@context" "https://schema.org"
|
||
|
|
"@type" "Recipe"
|
||
|
|
"name" .Title
|
||
|
|
"description" $description
|
||
|
|
"url" .Permalink
|
||
|
|
"image" $img
|
||
|
|
"author" (dict "@type" "Organization" "name" .Site.Title)
|
||
|
|
"recipeCategory" $category
|
||
|
|
"recipeIngredient" (.Params.ingredients | default (slice))
|
||
|
|
"recipeInstructions" (slice (dict "@type" "HowToStep" "text" (.Content | plainify | strings.TrimSpace)))
|
||
|
|
-}}
|
||
|
|
{{- printf "<script type=\"application/ld+json\">%s</script>" ($schema | jsonify) | safeHTML -}}
|
||
|
|
{{- end -}}
|