{{- /* Emits FAQPage structured data from the "Frequently Asked Questions" section of a page. Each h3 in that section is a question, the content up to the next h3 is the answer. The section ends at the next h2, or at a `` marker, whichever comes first. Add the marker after the last answer whenever other content (callouts, forms, media) follows the FAQ without a new h2, so that content is not read into the last answer. */ -}} {{- $faqs := slice -}} {{- range after 1 (split .Content "") 0 | plainify | htmlUnescape | strings.TrimSpace) "Frequently Asked Questions" -}} {{- $section := index (split . "") 0 -}} {{- range after 1 (split $section "" -}} {{- $question := index $parts 0 | plainify | htmlUnescape | strings.TrimSpace -}} {{- $answer := delimit (after 1 $parts) "" | plainify | htmlUnescape | replaceRE `\s+` " " | strings.TrimSpace -}} {{- if and $question $answer -}} {{- $faqs = $faqs | append (dict "@type" "Question" "name" $question "acceptedAnswer" (dict "@type" "Answer" "text" $answer)) -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- with $faqs }} {{- end -}}