forked from linode/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbody-structured-data.html
More file actions
62 lines (55 loc) · 1.93 KB
/
body-structured-data.html
File metadata and controls
62 lines (55 loc) · 1.93 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{{ $schemaCommonParts := partialCached "sections/head-structured-data-parts" . }}
{{ $img := (partial "funcs/get-social-image.html" .).img }}
{{ $p := .Params }}
{{ $author := $p.author }}
{{ $contributor := $p.contributor }}
{{ $authorName := $author.name }}
{{ if and (strings.Contains $authorName "Linode") $contributor }}
{{ with $contributor.name }}
{{ $authorName = . }}
{{ end }}
{{ end }}
{{ $author := dict }}
{{ if or (not $authorName) (strings.Contains $authorName "Linode") }}
{{ $author = $schemaCommonParts.publisher }}
{{ else }}
{{ $author = dict "@type" "Person" "name" $authorName }}
{{ end }}
{{ $mainEntityOfPage := dict "@type" "WebPage" "@id" .Permalink }}
{{ $schema := dict
"@context" "https://schema.org"
"@type" "NewsArticle"
"mainEntityOfPage" $mainEntityOfPage
"headline" .Title
"image" $img.Permalink
"datePublished" .PublishDate
"dateModified" .Lastmod
"author" $author
"publisher" $schemaCommonParts.publisher
}}
{{ $script := printf `<script type="application/ld+json">%s%s%s</script>` "\n\t" ($schema | jsonify ) "\n" }}
{{ $script | safeHTML }}
{{/* We also look for structured data in a file called structured-data.json in the same folder as the content file (index.md/_index.md) */}}
{{ $schemaFile := .Resources.GetMatch "structured-data.json" }}
{{ with $schemaFile }}
{{ with .Content }}
{{ $schema := . | transform.Unmarshal }}
{{ $script := printf `<script type="application/ld+json">%s%s%s</script>` "\n\t" ($schema | jsonify ) "\n" }}
{{ $script | safeHTML }}
{{ else }}
{{ end }}
{{ end }}
{{ define "partials/sections/head-structured-data-parts" }}
{{ $logo := "media/images/linode-logo-black.png" | absURL }}
{{ $publisher := printf `{
"@type": "Organization",
"name": "Linode",
"logo": {
"@type": "ImageObject",
"url": %q
}
}` $logo | transform.Unmarshal
}}
{{ $parts := dict "publisher" $publisher }}
{{ return $parts }}
{{ end }}