mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-23 22:15:45 +00:00
Allows to search content on the main page of docs/tutorials/courses. Previously, all docs pages except the main page were indexed.
29 lines
1.3 KiB
JSON
29 lines
1.3 KiB
JSON
{{- /* Generate the search index. */ -}}
|
|
{{- $index := slice -}}
|
|
{{- $pages := where .Site.RegularPages "Section" "!=" "home" -}}
|
|
{{- $pages := $pages | union (where (where .Site.Pages "Kind" "section") "Type" "docs") -}}
|
|
{{- /* TODO: Add author pages to index so their bios can be searched. */ -}}
|
|
{{- /* $pages := $pages | union (where (where .Site.Pages "Kind" "taxonomy") "taxonomyTerm" "author") */ -}}
|
|
|
|
{{- range $pages -}}
|
|
{{- /* Do not index drafts or private pages. */ -}}
|
|
{{- if and (not .Draft) (not .Params.private) -}}
|
|
|
|
{{- /* Generate page description. */ -}}
|
|
{{- $desc := "" -}}
|
|
{{- if .Params.summary -}}
|
|
{{- $desc = .Params.summary -}}
|
|
{{- else if .Params.abstract -}}
|
|
{{- $desc = .Params.abstract -}}
|
|
{{- else -}}
|
|
{{- $desc = .Summary -}}
|
|
{{- end -}}
|
|
|
|
{{- /* Add page to index. */ -}}
|
|
{{- $index = $index | append (dict "objectID" .UniqueID "date" .Date.UTC.Unix "publishdate" .PublishDate "lastmod" .Lastmod.UTC.Unix "expirydate" .ExpiryDate.UTC.Unix "lang" .Lang "permalink" .Permalink "relpermalink" .RelPermalink "title" .Title "summary" (plainify $desc) "content" .Plain "authors" .Params.Authors "kind" .Kind "type" .Type "section" .Section "tags" .Params.Tags "categories" .Params.Categories) -}}
|
|
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{- $index | jsonify -}}
|