diff options
author | Christoph Cullmann <cullmann@kde.org> | 2021-02-18 22:21:36 +0100 |
---|---|---|
committer | Christoph Cullmann <cullmann@kde.org> | 2021-02-18 22:21:36 +0100 |
commit | 0c7cb4486a89ec6fe9680e6569ef41d4b82d557d (patch) | |
tree | 081941052bcab0caf69487b6bf5ab2df5deb3b7b /themes/CodeIT/layouts/index.json | |
parent | 640572ecab69291d2c266de2011b795a861e7c21 (diff) |
use maintained theme
Diffstat (limited to 'themes/CodeIT/layouts/index.json')
-rw-r--r-- | themes/CodeIT/layouts/index.json | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/themes/CodeIT/layouts/index.json b/themes/CodeIT/layouts/index.json new file mode 100644 index 0000000..4e81039 --- /dev/null +++ b/themes/CodeIT/layouts/index.json @@ -0,0 +1,46 @@ +{{- if .Site.Params.search -}} + {{- $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 -}} + {{- $uri := .RelPermalink -}} + {{- if $.Site.Params.search.absoluteURL -}} + {{- $uri = .Permalink -}} + {{- end -}} + {{- $meta := dict "uri" $uri "title" .Title "tags" .Params.tags "categories" .Params.categories -}} + {{- $meta = $.Site.Params.dateFormat | default "2006-01-02" | .PublishDate.Format | dict "date" | merge $meta -}} + {{- with .Description -}} + {{- $index = $index | append (dict "content" . "objectID" $uri | merge $meta) -}} + {{- end -}} + {{- $params := .Params | merge $.Site.Params.page -}} + {{/* Extended Markdown syntax */}} + {{- $content := dict "Content" .Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" -}} + {{/* Remove line number for code */}} + {{- $content = $content | replaceRE `<span class="lnt?"> *\d*\n?</span>` "" -}} + {{- range $i, $contenti := split $content "<h2 id=" -}} + {{- if gt $i 0 -}} + {{- $contenti = printf "<h2 id=%v" $contenti -}} + {{- end -}} + {{- range $j, $contentj := split $contenti "<h3 id=" -}} + {{- if gt $j 0 -}} + {{- $contentj = printf "<h3 id=%v" $contentj -}} + {{- end -}} + {{/* Plainify, unescape and remove (\n, \t) */}} + {{- $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 "%v:%v:%v" $uri $i $j | dict "content" $contentj "objectID" | merge $meta -}} + {{- $index = $index | append $one -}} + {{- end -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- $index | jsonify | safeJS -}} +{{- end -}} |