aboutsummaryrefslogtreecommitdiffhomepage
path: root/layouts/shortcodes/json-ld-blog.html
blob: ef039ddffb8b7e98601adb3c9ad6d54c754e69ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{{- define "JSON-LD-blog" -}}
<script type="application/ld+json">
    {
        "@context": "https://schema.org/",
        "@type": "Article",
        "headline": "{{.Title}}",
        "datePublished": "{{ .Date | time.Format "2006-01-02T15:04" }}",
        {{- with .GetTerms "authors" }}
        "author": [
              {{- range $index, $el := . -}}
              {{- if ne $index 0 -}},{{ end }}
              {
               "@type": "Person",
               "name": {{- .LinkTitle }}
              }
              {{- end }}
           ],
        {{- end }}
        {{- with .Resources.ByType "image" }}
        "image":[
            {{- range $index, $element := . -}}
            {{- if ne $index 0 }},{{ end }}
            {{ .Permalink -}}
            {{ end }}
         ]
        {{- end }}
    }
  </script>
{{- end -}}