|
| 1 | +{{ if .IsHome }} |
| 2 | +<script type="application/ld+json"> |
| 3 | +{ |
| 4 | + "@context": "https://schema.org", |
| 5 | + "@type": "{{- ( site.Params.schema.publisherType | default "Organization") | title -}}", |
| 6 | + "name": {{ site.Title }}, |
| 7 | + "url": {{ site.BaseURL }}, |
| 8 | + "description": {{ site.Params.description | plainify | truncate 180 | safeHTML }}, |
| 9 | + "thumbnailUrl": {{ site.Params.assets.favicon | default "favicon.ico" | absURL }}, |
| 10 | + "sameAs": [ |
| 11 | + {{- if site.Params.schema.sameAs }} |
| 12 | + {{ range $i, $e := site.Params.schema.sameAs }}{{ if $i }}, {{ end }}{{ trim $e " " }}{{ end }} |
| 13 | + {{- else}} |
| 14 | + {{ range $i, $e := site.Params.SocialIcons }}{{ if $i }}, {{ end }}{{ trim $e.url " " }}{{ end }} |
| 15 | + {{- end}} |
| 16 | + ] |
| 17 | +} |
| 18 | +</script> |
| 19 | +{{- else if (or .IsPage .IsSection) }} |
| 20 | +{{/* BreadcrumbList */}} |
| 21 | +{{- $url := replace .Parent.Permalink ( printf "%s" site.BaseURL) "" }} |
| 22 | +{{- $lang_url := strings.TrimPrefix ( printf "%s/" .Lang) $url }} |
| 23 | +{{- $bc_list := (split $lang_url "/")}} |
| 24 | + |
| 25 | +{{- $scratch := newScratch }} |
| 26 | +<script type="application/ld+json"> |
| 27 | +{ |
| 28 | + "@context": "https://schema.org", |
| 29 | + "@type": "BreadcrumbList", |
| 30 | + "itemListElement": [ |
| 31 | + {{- range $index, $element := $bc_list }} |
| 32 | + |
| 33 | + {{- $scratch.Add "path" (printf "%s/" $element ) | safeJS }} |
| 34 | + {{- $bc_pg := site.GetPage ($scratch.Get "path") -}} |
| 35 | + |
| 36 | + {{- if (and ($bc_pg) (gt (len . ) 0))}} |
| 37 | + {{- if (and $index)}}, {{end }} |
| 38 | + { |
| 39 | + "@type": "ListItem", |
| 40 | + "position": {{ add 1 $index }}, |
| 41 | + "name": {{ $bc_pg.Name }}, |
| 42 | + "item": {{ $bc_pg.Permalink | safeHTML }} |
| 43 | + } |
| 44 | + {{- end }} |
| 45 | + |
| 46 | + {{- end }} |
| 47 | + {{- /* self-page addition */ -}} |
| 48 | + {{- if (ge (len $bc_list) 2) }}, {{end }} |
| 49 | + { |
| 50 | + "@type": "ListItem", |
| 51 | + "position": {{len $bc_list}}, |
| 52 | + "name": {{ .Name }}, |
| 53 | + "item": {{ .Permalink | safeHTML }} |
| 54 | + } |
| 55 | + ] |
| 56 | +} |
| 57 | +</script> |
| 58 | +{{- if .IsPage }} |
| 59 | +<script type="application/ld+json"> |
| 60 | +{ |
| 61 | + "@context": "https://schema.org", |
| 62 | + "@type": "BlogPosting", |
| 63 | + "headline": {{ .Title | plainify}}, |
| 64 | + "name": "{{ .Title | plainify }}", |
| 65 | + "description": {{ with .Description | plainify }}{{ . }}{{ else }}{{ .Summary | plainify }}{{ end -}}, |
| 66 | + "keywords": [ |
| 67 | + {{- if .Params.keywords }} |
| 68 | + {{ range $i, $e := .Params.keywords }}{{ if $i }}, {{ end }}{{ $e }}{{ end }} |
| 69 | + {{- else }} |
| 70 | + {{ range $i, $e := .Params.tags }}{{ if $i }}, {{ end }}{{ $e }}{{ end }} |
| 71 | + {{- end }} |
| 72 | + ], |
| 73 | + "articleBody": {{ .Content | safeJS | htmlUnescape | plainify }}, |
| 74 | + "wordCount" : "{{ .WordCount }}", |
| 75 | + "inLanguage": {{ .Language.Lang | default "en-us" }}, |
| 76 | + {{ if .Params.cover.image -}} |
| 77 | + "image": |
| 78 | + {{- if (ne .Params.cover.relative true) -}} |
| 79 | + {{ .Params.cover.image | absURL }}, |
| 80 | + {{- else -}} |
| 81 | + {{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}, |
| 82 | + {{- end}} |
| 83 | + {{- end -}} |
| 84 | + "datePublished": {{ .PublishDate }}, |
| 85 | + "dateModified": {{ .Lastmod }}, |
| 86 | + {{- with (.Params.author | default site.Params.author) }} |
| 87 | + "author": |
| 88 | + {{- if (or (eq (printf "%T" .) "[]string") (eq (printf "%T" .) "[]interface {}")) -}} |
| 89 | + [{{- range $i, $v := . -}} |
| 90 | + {{- if $i }}, {{end -}} |
| 91 | + { |
| 92 | + "@type": "Person", |
| 93 | + "name": {{ $v }} |
| 94 | + } |
| 95 | + {{- end }}], |
| 96 | + {{- else -}} |
| 97 | + { |
| 98 | + "@type": "Person", |
| 99 | + "name": {{ . }} |
| 100 | + }, |
| 101 | + {{- end -}} |
| 102 | + {{- end }} |
| 103 | + "mainEntityOfPage": { |
| 104 | + "@type": "WebPage", |
| 105 | + "@id": {{ .Permalink | safeHTML }} |
| 106 | + }, |
| 107 | + "publisher": { |
| 108 | + "@type": "{{- ( site.Params.schema.publisherType | default "Organization") | title -}}", |
| 109 | + "name": {{ site.Title }}, |
| 110 | + "logo": { |
| 111 | + "@type": "ImageObject", |
| 112 | + "url": {{ site.Params.assets.favicon | default "favicon.ico" | absURL }} |
| 113 | + } |
| 114 | + } |
| 115 | +} |
| 116 | +</script> |
| 117 | +{{- end }}{{/* .IsPage end */}} |
| 118 | + |
| 119 | +{{- end -}} |
0 commit comments