From 312a9542eb24a2046145376f1fa4a4250a8666f8 Mon Sep 17 00:00:00 2001 From: Joe <4088382+JoeStech@users.noreply.github.com> Date: Wed, 9 Jul 2025 17:15:23 -0600 Subject: [PATCH 1/2] first iteration of json-ld --- .../layouts/partials/head/head.html | 2 + .../layouts/partials/head/jsonld.html | 67 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 themes/arm-design-system-hugo-theme/layouts/partials/head/jsonld.html diff --git a/themes/arm-design-system-hugo-theme/layouts/partials/head/head.html b/themes/arm-design-system-hugo-theme/layouts/partials/head/head.html index 3b0f7a0b11..f7e96d3007 100644 --- a/themes/arm-design-system-hugo-theme/layouts/partials/head/head.html +++ b/themes/arm-design-system-hugo-theme/layouts/partials/head/head.html @@ -26,6 +26,8 @@ {{ $title }} +{{ partial "head/jsonld.html" . }} + diff --git a/themes/arm-design-system-hugo-theme/layouts/partials/head/jsonld.html b/themes/arm-design-system-hugo-theme/layouts/partials/head/jsonld.html new file mode 100644 index 0000000000..d9ffaf085d --- /dev/null +++ b/themes/arm-design-system-hugo-theme/layouts/partials/head/jsonld.html @@ -0,0 +1,67 @@ +{{/* layouts/partials/head/jsonld.html */}} + +{{/* --------------------------------------------------------------- + Render JSON‑LD only for Learning‑Path _index.md main pages +---------------------------------------------------------------- */}} +{{- if and .IsSection (eq .Params.learning_path_main_page "yes") -}} + + {{/* -------- Helper : Build ISO‑8601 duration (PT30M, PT2H, …) */}} + {{- $duration := "" -}} + {{- with .Params.minutes_to_complete -}} + {{- $duration = printf "PT%dM" (int .) -}} + {{- end -}} + + {{/* -------- Learning objectives & prerequisites */}} + {{- $objectives := slice -}} + {{- with .Params.learning_objectives -}} + {{- range . }}{{ $objectives = $objectives | append ( . | plainify ) }}{{ end -}} + {{- end -}} + + {{- $prereqs := slice -}} + {{- with .Params.prerequisites -}} + {{- range . }}{{ $prereqs = $prereqs | append ( . | plainify ) }}{{ end -}} + {{- end -}} + + {{/* -------- Collect tag‑style params into one keywords list */}} + {{- $keywords := slice -}} + {{- $tagParams := slice + "skilllevels" + "cloud_service_providers" + "armips" + "subjects" + "operatingsystems" + "tools_software_languages" + -}} + {{- range $tagParams -}} + {{- $v := index $.Params . -}} + {{- with $v -}} + {{- if reflect.IsSlice $v -}} + {{- range $v }}{{ $keywords = $keywords | append ( . | plainify ) }}{{ end -}} + {{- else -}} + {{- $keywords = $keywords | append ( $v | plainify ) -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{/* -------- Assemble JSON‑LD dict */}} + {{- $j := dict + "@context" "https://schema.org" + "@type" "Course" + "name" .Title + -}} + + {{- with .Params.who_is_this_for }}{{ $j = merge $j (dict "description" ( . | plainify )) }}{{ end -}} + {{- if $duration }}{{ $j = merge $j (dict "timeRequired" $duration) }}{{ end -}} + {{- with .Params.skilllevels }}{{ $j = merge $j (dict "educationalLevel" .) }}{{ end -}} + {{- with $objectives }}{{ if gt (len .) 0 }}{{ $j = merge $j (dict "teaches" .) }}{{ end }}{{ end -}} + {{- with $prereqs }}{{ if gt (len .) 0 }}{{ $j = merge $j (dict "competencyRequired" .) }}{{ end }}{{ end -}} + {{- with .Params.author }}{{ $j = merge $j (dict "author" (dict "@type" "Person" "name" .)) }}{{ end -}} + {{- if $keywords }}{{ $j = merge $j (dict "keywords" (delimit (uniq $keywords) ", ")) }}{{ end -}} + {{- with .Site.Title }}{{ $j = merge $j (dict "provider" (dict "@type" "Organization" "name" .)) }}{{ end -}} + + {{/* -------- Emit into */}} + + +{{- end -}} \ No newline at end of file From 7694067d7be7511d184ed1f701b1314104e9abd9 Mon Sep 17 00:00:00 2001 From: Joe <4088382+JoeStech@users.noreply.github.com> Date: Wed, 30 Jul 2025 16:35:19 -0600 Subject: [PATCH 2/2] fix quote wrapping --- .../layouts/partials/head/jsonld.html | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/themes/arm-design-system-hugo-theme/layouts/partials/head/jsonld.html b/themes/arm-design-system-hugo-theme/layouts/partials/head/jsonld.html index d9ffaf085d..49f858bb4a 100644 --- a/themes/arm-design-system-hugo-theme/layouts/partials/head/jsonld.html +++ b/themes/arm-design-system-hugo-theme/layouts/partials/head/jsonld.html @@ -1,27 +1,22 @@ {{/* layouts/partials/head/jsonld.html */}} - {{/* --------------------------------------------------------------- Render JSON‑LD only for Learning‑Path _index.md main pages ---------------------------------------------------------------- */}} {{- if and .IsSection (eq .Params.learning_path_main_page "yes") -}} - {{/* -------- Helper : Build ISO‑8601 duration (PT30M, PT2H, …) */}} {{- $duration := "" -}} {{- with .Params.minutes_to_complete -}} {{- $duration = printf "PT%dM" (int .) -}} {{- end -}} - {{/* -------- Learning objectives & prerequisites */}} {{- $objectives := slice -}} {{- with .Params.learning_objectives -}} {{- range . }}{{ $objectives = $objectives | append ( . | plainify ) }}{{ end -}} {{- end -}} - {{- $prereqs := slice -}} {{- with .Params.prerequisites -}} {{- range . }}{{ $prereqs = $prereqs | append ( . | plainify ) }}{{ end -}} {{- end -}} - {{/* -------- Collect tag‑style params into one keywords list */}} {{- $keywords := slice -}} {{- $tagParams := slice @@ -42,14 +37,12 @@ {{- end -}} {{- end -}} {{- end -}} - {{/* -------- Assemble JSON‑LD dict */}} {{- $j := dict "@context" "https://schema.org" "@type" "Course" "name" .Title -}} - {{- with .Params.who_is_this_for }}{{ $j = merge $j (dict "description" ( . | plainify )) }}{{ end -}} {{- if $duration }}{{ $j = merge $j (dict "timeRequired" $duration) }}{{ end -}} {{- with .Params.skilllevels }}{{ $j = merge $j (dict "educationalLevel" .) }}{{ end -}} @@ -58,10 +51,9 @@ {{- with .Params.author }}{{ $j = merge $j (dict "author" (dict "@type" "Person" "name" .)) }}{{ end -}} {{- if $keywords }}{{ $j = merge $j (dict "keywords" (delimit (uniq $keywords) ", ")) }}{{ end -}} {{- with .Site.Title }}{{ $j = merge $j (dict "provider" (dict "@type" "Organization" "name" .)) }}{{ end -}} - {{/* -------- Emit into */}} - - + {{- end -}} \ No newline at end of file