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

search.json « page « layouts - github.com/CaiJimmy/hugo-theme-stack.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a0f518419f90ccf16e90e74f32bc1aa529511b9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{{- $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections -}}
{{- $result := slice -}}

{{- range $pages -}}
    {{- $data := dict "title" .Title "date" .Date "permalink" .Permalink "content" (.Plain) -}}

    {{- $image := partialCached "helper/image" (dict "Context" . "Type" "articleList") .RelPermalink "articleList" -}}
    {{- if $image.exists -}}
        {{- $imagePermalink := "" -}}
        {{- if and $image.resource .Page.Site.Params.imageProcessing.cover.enabled -}}
            {{- $thumbnail := $image.resource.Fill "120x120" -}}
            {{- $imagePermalink = (absURL $thumbnail.Permalink) -}}
        {{- else -}}
            {{- $imagePermalink = $image.permalink -}}
        {{- end -}}
        
        {{- $data = merge $data (dict "image" (absURL $imagePermalink)) -}}
    {{- end -}}

    {{- $result = $result | append $data -}}
{{- end -}}

{{ jsonify $result }}