LoveIt/layouts/index.json
2020-04-28 12:53:06 +08:00

21 lines
1,016 B
JSON

{{- $index := slice -}}
{{- $pages := .Site.RegularPages -}}
{{- if .Site.Params.page.hiddenFromSearch -}}
{{- $pages = where $pages "Params.hiddenfromsearch" false -}}
{{- else -}}
{{- $pages = where $pages "Params.hiddenfromsearch" "!=" true -}}
{{- end -}}
{{- range $pages -}}
{{- $one := dict "objectID" .RelPermalink "uri" .RelPermalink "title" .Title "description" (.Description | default "") -}}
{{- $tags := .Params.tags | default slice -}}
{{- $one = delimit $tags "\n" | dict "tags" | merge $one -}}
{{- $publish_date := .PublishDate.Format (.Site.Params.dateFormat | default "2006-01-02") -}}
{{- $one = dict "date" $publish_date | merge $one -}}
{{- $content := .RawContent -}}
{{- if gt .Site.Params.search.contentLength 0 -}}
{{- $content = substr $content 0 .Site.Params.search.contentLength -}}
{{- end -}}
{{- $one = dict "content" $content | merge $one -}}
{{- $index = $index | append $one -}}
{{- end -}}
{{- $index | jsonify | safeJS -}}