Skip to content

Commit

Permalink
fix: add faq example
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-au committed Sep 24, 2022
1 parent a60e4b6 commit 34c1dee
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .examples/jsonld/faq.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{{/*
faq.html example partial

@author Sean Emerson @sean-au

@access public

@context params as per readme, page available in .page, site in site

@example usage - see add-tags.html

@example frontmatter to generate faq json-ld:

---
title: Home
params:
faqItems:
- question: Question 1 text
answer: Question 1 answer
- question: Question 2 text
answer: Question 2 answer
---
*/}}
{{ $s := newScratch }}
{{ $s.Set "faq" dict }}
{{ $s.Set "mainEntityItems" slice }}

{{ $s.SetInMap "faq" "@context" "https://schema.org" }}

{{ range .Params.faqItems }}
{{ $item = (dict
"@type" "Question"
"name" .question
"acceptedAnswer" (dict
"@type": "answer"
"text": .answer
)
)}}
{{ $s.SetInMap "mainEntityItems" (slice $item) }}
{{ end }}

{{ $s.SetInMap "faq" "mainEntity" ($s.Get "mainEntityItems") }}

{{ return $s.Get "faq" }}

0 comments on commit 34c1dee

Please sign in to comment.