2020-04-15 09:46:50 +02:00
|
|
|
{{- $index := slice -}}
|
2020-04-21 16:55:06 +02:00
|
|
|
{{- $pages := .Site.RegularPages -}}
|
|
|
|
{{- if .Site.Params.page.hiddenFromSearch -}}
|
|
|
|
{{- $pages = where $pages "Params.hiddenfromsearch" false -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- $pages = where $pages "Params.hiddenfromsearch" "!=" true -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- range $pages -}}
|
2020-04-28 20:34:28 +02:00
|
|
|
{{- $uri := .RelPermalink -}}
|
|
|
|
{{- $meta := dict "uri" $uri "title" .Title "tags" .Params.tags "categories" .Params.categories -}}
|
|
|
|
{{- $meta = .PublishDate.Format ($.Site.Params.dateFormat | default "2006-01-02") | dict "date" | merge $meta -}}
|
|
|
|
{{- with .Description -}}
|
|
|
|
{{- $index = $index | append (dict "content" . "objectID" $uri | merge $meta) -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- $params := .Params | merge $.Site.Params.page -}}
|
2020-04-30 18:05:38 +02:00
|
|
|
{{/* Extended Markdown syntax */}}
|
2020-04-28 20:34:28 +02:00
|
|
|
{{- $content := dict "content" .Content "ruby" $params.ruby "fraction" $params.fraction "fontawesome" $params.fontawesome | partial "function/content.html" -}}
|
2020-04-30 18:05:38 +02:00
|
|
|
{{/* Remove line number for code */}}
|
|
|
|
{{- $content = $content | replaceRE `<span class="lnt?"> *\d*\n?</span>` "" -}}
|
2020-04-29 21:22:52 +02:00
|
|
|
{{- range $i, $contenti := split $content "<h2 id=" -}}
|
2020-04-28 20:34:28 +02:00
|
|
|
{{- if gt $i 0 -}}
|
2020-04-29 21:22:52 +02:00
|
|
|
{{- $contenti = printf "<h2 id=%s" $contenti -}}
|
2020-04-28 20:34:28 +02:00
|
|
|
{{- end -}}
|
2020-04-29 21:22:52 +02:00
|
|
|
{{- range $j, $contentj := split $contenti "<h3 id=" -}}
|
|
|
|
{{- if gt $j 0 -}}
|
|
|
|
{{- $contentj = printf "<h3 id=%s" $contentj -}}
|
|
|
|
{{- end -}}
|
2020-04-30 18:05:38 +02:00
|
|
|
{{/* Plainify, unescape and remove (\n, \t) */}}
|
2020-04-29 21:22:52 +02:00
|
|
|
{{- $contentj = $contentj | plainify | htmlUnescape | replaceRE `[\n\t ]+` " " -}}
|
|
|
|
{{- if gt $.Site.Params.search.contentLength 0 -}}
|
|
|
|
{{- $contentj = substr $contentj 0 $.Site.Params.search.contentLength -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- if $contentj | and (ne $contentj " ") -}}
|
|
|
|
{{- $one := printf "%s:%d:%d" $uri $i $j | dict "content" $contentj "objectID" | merge $meta -}}
|
|
|
|
{{- $index = $index | append $one -}}
|
|
|
|
{{- end -}}
|
2020-04-28 20:34:28 +02:00
|
|
|
{{- end -}}
|
2020-04-15 09:46:50 +02:00
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|
2020-04-28 20:34:28 +02:00
|
|
|
|
2020-04-15 09:46:50 +02:00
|
|
|
{{- $index | jsonify | safeJS -}}
|