From 0bba01c343662cedf633c82ea24f9c0303bb2ce4 Mon Sep 17 00:00:00 2001 From: "Kyle J. Davis" Date: Thu, 19 Oct 2023 14:30:43 -0600 Subject: [PATCH] rewrites faqlist shortcode, refactors faq template, and renames files --- ...n => 1_1-access-regaining-access.markdown} | 0 ...s-how-do-i-ssh-into-bottlerocket.markdown} | 0 ...rnetes-how-to-do-fault-injection.markdown} | 0 ...nage-onprem-node-like-cloud-node.markdown} | 0 ...mmutability-files-change-on-host.markdown} | 0 ...-scanning-cluster-software-vulns.markdown} | 0 ... 4_3-security-disable-secureboot.markdown} | 0 ...1-settings-what-language-is-used.markdown} | 0 ...hooting-bootstrap-container-logs.markdown} | 0 ...=> 7_1-updates-how-long-variants.markdown} | 0 layouts/partials/faq-body.html | 14 ++++ layouts/partials/faq-index.html | 15 ++++ layouts/shortcodes/faqlist.html | 82 ++++++++----------- 13 files changed, 63 insertions(+), 48 deletions(-) rename content/en/faqitems/{access-1-regaining-access.markdown => 1_1-access-regaining-access.markdown} (100%) rename content/en/faqitems/{access-2-how-do-i-ssh-into-bottlerocket.markdown => 1_2-access-how-do-i-ssh-into-bottlerocket.markdown} (100%) rename content/en/faqitems/{kubernetes-1-how-to-do-fault-injection.markdown => 2_1-kubernetes-how-to-do-fault-injection.markdown} (100%) rename content/en/faqitems/{on-prem-1-manage-onprem-node-like-cloud-node.markdown => 3_1-on-prem-manage-onprem-node-like-cloud-node.markdown} (100%) rename content/en/faqitems/{security-1-immutability-files-change-on-host.markdown => 4_1-security-immutability-files-change-on-host.markdown} (100%) rename content/en/faqitems/{security-2-scanning-cluster-software-vulns.markdown => 4_2-security-scanning-cluster-software-vulns.markdown} (100%) rename content/en/faqitems/{security-3-disable-secureboot.markdown => 4_3-security-disable-secureboot.markdown} (100%) rename content/en/faqitems/{settings-1-what-language-is-used.markdown => 5_1-settings-what-language-is-used.markdown} (100%) rename content/en/faqitems/{troubleshooting-1-bootstrap-container-logs.markdown => 6_1-troubleshooting-bootstrap-container-logs.markdown} (100%) rename content/en/faqitems/{updates-1-how-long-variants.markdown => 7_1-updates-how-long-variants.markdown} (100%) create mode 100644 layouts/partials/faq-body.html create mode 100644 layouts/partials/faq-index.html diff --git a/content/en/faqitems/access-1-regaining-access.markdown b/content/en/faqitems/1_1-access-regaining-access.markdown similarity index 100% rename from content/en/faqitems/access-1-regaining-access.markdown rename to content/en/faqitems/1_1-access-regaining-access.markdown diff --git a/content/en/faqitems/access-2-how-do-i-ssh-into-bottlerocket.markdown b/content/en/faqitems/1_2-access-how-do-i-ssh-into-bottlerocket.markdown similarity index 100% rename from content/en/faqitems/access-2-how-do-i-ssh-into-bottlerocket.markdown rename to content/en/faqitems/1_2-access-how-do-i-ssh-into-bottlerocket.markdown diff --git a/content/en/faqitems/kubernetes-1-how-to-do-fault-injection.markdown b/content/en/faqitems/2_1-kubernetes-how-to-do-fault-injection.markdown similarity index 100% rename from content/en/faqitems/kubernetes-1-how-to-do-fault-injection.markdown rename to content/en/faqitems/2_1-kubernetes-how-to-do-fault-injection.markdown diff --git a/content/en/faqitems/on-prem-1-manage-onprem-node-like-cloud-node.markdown b/content/en/faqitems/3_1-on-prem-manage-onprem-node-like-cloud-node.markdown similarity index 100% rename from content/en/faqitems/on-prem-1-manage-onprem-node-like-cloud-node.markdown rename to content/en/faqitems/3_1-on-prem-manage-onprem-node-like-cloud-node.markdown diff --git a/content/en/faqitems/security-1-immutability-files-change-on-host.markdown b/content/en/faqitems/4_1-security-immutability-files-change-on-host.markdown similarity index 100% rename from content/en/faqitems/security-1-immutability-files-change-on-host.markdown rename to content/en/faqitems/4_1-security-immutability-files-change-on-host.markdown diff --git a/content/en/faqitems/security-2-scanning-cluster-software-vulns.markdown b/content/en/faqitems/4_2-security-scanning-cluster-software-vulns.markdown similarity index 100% rename from content/en/faqitems/security-2-scanning-cluster-software-vulns.markdown rename to content/en/faqitems/4_2-security-scanning-cluster-software-vulns.markdown diff --git a/content/en/faqitems/security-3-disable-secureboot.markdown b/content/en/faqitems/4_3-security-disable-secureboot.markdown similarity index 100% rename from content/en/faqitems/security-3-disable-secureboot.markdown rename to content/en/faqitems/4_3-security-disable-secureboot.markdown diff --git a/content/en/faqitems/settings-1-what-language-is-used.markdown b/content/en/faqitems/5_1-settings-what-language-is-used.markdown similarity index 100% rename from content/en/faqitems/settings-1-what-language-is-used.markdown rename to content/en/faqitems/5_1-settings-what-language-is-used.markdown diff --git a/content/en/faqitems/troubleshooting-1-bootstrap-container-logs.markdown b/content/en/faqitems/6_1-troubleshooting-bootstrap-container-logs.markdown similarity index 100% rename from content/en/faqitems/troubleshooting-1-bootstrap-container-logs.markdown rename to content/en/faqitems/6_1-troubleshooting-bootstrap-container-logs.markdown diff --git a/content/en/faqitems/updates-1-how-long-variants.markdown b/content/en/faqitems/7_1-updates-how-long-variants.markdown similarity index 100% rename from content/en/faqitems/updates-1-how-long-variants.markdown rename to content/en/faqitems/7_1-updates-how-long-variants.markdown diff --git a/layouts/partials/faq-body.html b/layouts/partials/faq-body.html new file mode 100644 index 00000000..3455fe91 --- /dev/null +++ b/layouts/partials/faq-body.html @@ -0,0 +1,14 @@ + +{{- $questions := .questions -}} +{{- range .groups -}} + {{- $group_name := . -}} +

{{ $group_name }}

+ +
+ {{- range (sort (index $questions $group_name) "question" ) -}} +

{{ .question }}

+ {{ .answer }} + {{- end -}} +
+
+{{- end -}} diff --git a/layouts/partials/faq-index.html b/layouts/partials/faq-index.html new file mode 100644 index 00000000..2ac6cbc3 --- /dev/null +++ b/layouts/partials/faq-index.html @@ -0,0 +1,15 @@ +
    + {{- $questions := .questions -}} + {{- range .groups -}} + {{- $group_name := . -}} +
  1. {{ $group_name }} +
      + {{- range (sort (index $questions $group_name) "question" ) -}} +
    1. + {{ .question }} +
    2. + {{- end -}} +
    +
  2. + {{ end }} +
\ No newline at end of file diff --git a/layouts/shortcodes/faqlist.html b/layouts/shortcodes/faqlist.html index ca7560f0..4bbd0730 100644 --- a/layouts/shortcodes/faqlist.html +++ b/layouts/shortcodes/faqlist.html @@ -1,49 +1,35 @@ -{{ $groups := slice }} -{{ $headless := .Site.GetPage "/faqitems" }} -{{ $faqItems := $headless.Resources.Match "*" }} -{{ range $faqItems }} - {{ $groups = $groups | append .Params.group }} -{{ end }} -{{ $groups = uniq $groups }} - +{{- $groups := slice -}} +{{- $headless := .Site.GetPage "/faqitems" -}} +{{- $faq_items := $headless.Resources.Match "*" -}} + +{{- $grouped := dict -}} + +{{- $hash_links := slice -}} + +{{- range $k, $v := $faq_items -}} + {{- $hash := (index (split (path.BaseName ($v.Page.File)) "-") 0) -}} + {{- $hash_links = $hash_links | append $hash -}} + {{- $group := $v.Params.group -}} + + {{- if not ( reflect.IsSlice (index $grouped $group) ) -}} + {{- $grouped = merge $grouped (dict $group ( slice ) ) -}} + {{- end -}} + + {{- $this_item := dict "hash" $hash "question" $v.Page.Params.question "answer" $v.Page.Content -}} + {{- $this_group := index $grouped $group | append $this_item -}} + {{- $grouped = merge $grouped (dict $group ( $this_group ) ) -}} + + {{- $groups = $groups | append .Params.group -}} +{{- end -}} + +{{- $unique_hashes := $hash_links | uniq | len -}} +{{- $total_faq_items := $faq_items | len -}} +{{- if ne $unique_hashes $total_faq_items -}} + {{- errorf "Oops! You have %d faq items and %d unique hash links. Check for duplicate IDs in faq file names." $total_faq_items $unique_hashes -}} +{{- end -}} + +{{- $faq := dict "groups" (sort (uniq $groups) ) "questions" $grouped -}} + +{{- partial "faq-index.html" $faq -}}
-{{ $.Scratch.Set "groupindex" 0 }} -{{ range $groups }} - {{ $group := . }} - {{ $.Scratch.Set "groupindex" - (add ($.Scratch.Get "groupindex") 1) - }} -

{{ $.Scratch.Get "groupindex" }}. {{ $group }}

-
- {{ $.Scratch.Set "qindex" 0 }} - {{ range where $faqItems "Params.group" $group }} - {{ $.Scratch.Set "qindex" - (add ($.Scratch.Get "qindex") 1) - }} -

{{ $.Scratch.Get "groupindex" }}.{{ $.Scratch.Get "qindex" }} {{ .Params.question }}

- {{ .Content }} - {{ end }} -
- -
-{{ end }} +{{- partial "faq-body.html" $faq -}}