index.json 1.3 KB

1234567891011121314151617181920212223242526272829
  1. {{- /* Generate the search index. */ -}}
  2. {{- $index := slice -}}
  3. {{- $pages := where .Site.RegularPages "Section" "!=" "home" -}}
  4. {{- /* Add the index page of docs separately since it's not in RegularPages above. */ -}}
  5. {{- $pages := $pages | union (where (where .Site.Pages "Kind" "section") "Type" "docs") -}}
  6. {{- /* Add author pages to index so their bios can be searched. */ -}}
  7. {{- $pages := $pages | union (where $.Site.Pages "Section" "author") -}}
  8. {{- range $pages -}}
  9. {{- /* Do not index drafts or private pages. */ -}}
  10. {{- if and (not .Draft) (not .Params.private) -}}
  11. {{- /* Generate page description. */ -}}
  12. {{- $desc := "" -}}
  13. {{- if .Params.summary -}}
  14. {{- $desc = .Params.summary -}}
  15. {{- else if .Params.abstract -}}
  16. {{- $desc = .Params.abstract -}}
  17. {{- else -}}
  18. {{- $desc = .Summary -}}
  19. {{- end -}}
  20. {{- /* Add page to index. */ -}}
  21. {{- $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) -}}
  22. {{- end -}}
  23. {{- end -}}
  24. {{- $index | jsonify -}}