Welcome to mirror list, hosted at ThFree Co, Russian Federation.

index.json « layouts - github.com/uPagge/uBlogger.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4e810391f76842b2042c5ab5c5ae4daf2c26c29d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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 -}}