1+ {{/* layouts/partials/head/jsonld.html */}}
2+ {{/* ---------------------------------------------------------------
3+ Render JSON‑LD only for Learning‑Path _index.md main pages
4+ ---------------------------------------------------------------- */}}
5+ {{- if and .IsSection (eq .Params.learning_path_main_page "yes") -}}
6+ {{/* -------- Helper : Build ISO‑8601 duration (PT30M, PT2H, …) */}}
7+ {{- $duration := "" -}}
8+ {{- with .Params.minutes_to_complete -}}
9+ {{- $duration = printf "PT%dM" (int .) -}}
10+ {{- end -}}
11+ {{/* -------- Learning objectives & prerequisites */}}
12+ {{- $objectives := slice -}}
13+ {{- with .Params.learning_objectives -}}
14+ {{- range . }}{{ $objectives = $objectives | append ( . | plainify ) }}{{ end -}}
15+ {{- end -}}
16+ {{- $prereqs := slice -}}
17+ {{- with .Params.prerequisites -}}
18+ {{- range . }}{{ $prereqs = $prereqs | append ( . | plainify ) }}{{ end -}}
19+ {{- end -}}
20+ {{/* -------- Collect tag‑style params into one keywords list */}}
21+ {{- $keywords := slice -}}
22+ {{- $tagParams := slice
23+ "skilllevels"
24+ "cloud_service_providers"
25+ "armips"
26+ "subjects"
27+ "operatingsystems"
28+ "tools_software_languages"
29+ -}}
30+ {{- range $tagParams -}}
31+ {{- $v := index $.Params . -}}
32+ {{- with $v -}}
33+ {{- if reflect.IsSlice $v -}}
34+ {{- range $v }}{{ $keywords = $keywords | append ( . | plainify ) }}{{ end -}}
35+ {{- else -}}
36+ {{- $keywords = $keywords | append ( $v | plainify ) -}}
37+ {{- end -}}
38+ {{- end -}}
39+ {{- end -}}
40+ {{/* -------- Assemble JSON‑LD dict */}}
41+ {{- $j := dict
42+ "@context" "https://schema.org"
43+ "@type" "Course"
44+ "name" .Title
45+ -}}
46+ {{- with .Params.who_is_this_for }}{{ $j = merge $j (dict "description" ( . | plainify )) }}{{ end -}}
47+ {{- if $duration }}{{ $j = merge $j (dict "timeRequired" $duration) }}{{ end -}}
48+ {{- with .Params.skilllevels }}{{ $j = merge $j (dict "educationalLevel" .) }}{{ end -}}
49+ {{- with $objectives }}{{ if gt (len .) 0 }}{{ $j = merge $j (dict "teaches" .) }}{{ end }}{{ end -}}
50+ {{- with $prereqs }}{{ if gt (len .) 0 }}{{ $j = merge $j (dict "competencyRequired" .) }}{{ end }}{{ end -}}
51+ {{- with .Params.author }}{{ $j = merge $j (dict "author" (dict "@type" "Person" "name" .)) }}{{ end -}}
52+ {{- if $keywords }}{{ $j = merge $j (dict "keywords" (delimit (uniq $keywords) ", ")) }}{{ end -}}
53+ {{- with .Site.Title }}{{ $j = merge $j (dict "provider" (dict "@type" "Organization" "name" .)) }}{{ end -}}
54+ {{/* -------- Emit into < head > */}}
55+ < script type ="application/ld+json ">
56+ { { - /* prettify the JSON (2‑space indent) and mark it as safe JS */ - } }
57+ { { - $j | jsonify ( dict "indent" " " ) | safeJS - } }
58+ </ script >
59+ {{- end -}}
0 commit comments