Files
hextra/assets/json/search-data.json

38 lines
1.3 KiB
JSON
Raw Normal View History

{{/* FlexSearch Index Data */}}
{{- $indexType := site.Params.search.flexsearch.index | default "content" -}}
{{- if not (in (slice "content" "summary" "heading" "title" ) $indexType) -}}
{{- errorf "unknown flexsearch index type: %s" $indexType -}}
{{- end -}}
2023-08-04 01:11:31 +01:00
{{- $pages := where .Site.Pages "Kind" "in" (slice "page" "section") -}}
{{- $pages = where $pages "Params.excludeSearch" "!=" true -}}
{{- $pages = where $pages "Content" "!=" "" -}}
2023-08-04 01:11:31 +01:00
{{- $output := dict -}}
2023-08-04 01:11:31 +01:00
{{- range $index, $page := $pages -}}
{{- $pageTitle := $page.LinkTitle | default $page.File.BaseFileName -}}
{{- $pageLink := $page.RelPermalink -}}
{{- $data := partial "utils/fragments" (dict "context" $page "type" $indexType) -}}
{{- $output = $output | merge (dict $pageLink (dict "title" $pageTitle "data" $data)) -}}
{{- end -}}
{{/* Extract glossary data entries */}}
{{- $glossaryEntries := dict -}}
{{- with (index .Site.Data .Site.Language.Lang "termbase") -}}
{{- range . -}}
{{- $entry := cond (.abbr) (printf "%s %s %s" .abbr .term .definition) (printf "%s %s" .term .definition) -}}
{{- $glossaryEntries = $glossaryEntries | merge (dict .term $entry) -}}
{{- end -}}
{{- end -}}
{{- $glossary := dict
"title" "Glossary"
"data" $glossaryEntries
-}}
{{- $output = $output | merge (dict (relLangURL "glossary") $glossary )}}
{{- $output | jsonify -}}