summaryrefslogtreecommitdiffstats
path: root/layouts
diff options
context:
space:
mode:
authorSerghei Iakovlev <egrep@protonmail.ch>2022-07-10 23:43:11 +0200
committerSerghei Iakovlev <egrep@protonmail.ch>2022-07-10 23:43:11 +0200
commitbd2d8cc841343dd6a66e5dbd53d735b0ea7e3d61 (patch)
tree73f763ce1b5800c59c34aaca8031f7b89b76d9be /layouts
parent0a51ffccb6c6c2213300fc77f41a6faa7aab0cf9 (diff)
downloadgohugo-theme-ed-bd2d8cc841343dd6a66e5dbd53d735b0ea7e3d61.tar.gz
Move layouts/_default/list.json to layouts/index.json
Diffstat (limited to 'layouts')
-rw-r--r--layouts/_default/list.json29
-rw-r--r--layouts/index.json25
2 files changed, 25 insertions, 29 deletions
diff --git a/layouts/_default/list.json b/layouts/_default/list.json
deleted file mode 100644
index 5742bb3..0000000
--- a/layouts/_default/list.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{{- $pctx := . -}}
-{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
-
-{{- $pages := slice -}}
-{{- if $.IsHome -}}
- {{- $mainSections := site.Params.mainSections | default (slice "posts") }}
- {{- $pages = where $pctx.RegularPages.ByDate.Reverse "Type" "in" $mainSections -}}
-{{- else if $.IsSection -}}
- {{- $pages = $pctx.RegularPages.ByDate.Reverse -}}
-{{- else -}}
- {{- $pages = $pctx.Pages -}}
-{{- end -}}
-
-{{- $.Scratch.Add "pagesIndex" slice -}}
-
-{{- range $index, $page := $pages -}}
- {{- if gt (len $page.Content) 0 -}}
- {{- $pageData := (dict
- "title" $page.Title
- "href" $page.Permalink
- "tags" (delimit ($page.Params.tags | default slice) " ; ")
- "categories" (delimit ($page.Params.categories | default slice) " ; ")
- "content" $page.Plain
- ) -}}
- {{- $.Scratch.Add "pagesIndex" $pageData -}}
- {{- end -}}
-{{- end -}}
-
-{{- $.Scratch.Get "pagesIndex" | jsonify -}}
diff --git a/layouts/index.json b/layouts/index.json
new file mode 100644
index 0000000..05d731f
--- /dev/null
+++ b/layouts/index.json
@@ -0,0 +1,25 @@
+{{- $pages := slice -}}
+
+{{- $mainSections := site.Params.mainSections | default (slice "posts") }}
+{{- $pages = where site.RegularPages.ByDate.Reverse "Type" "in" $mainSections -}}
+
+{{- $.Scratch.Add "pagesIndex" slice -}}
+{{- $.Scratch.Add "urlsAdded" slice -}}
+
+{{- range $index, $page := $pages -}}
+ {{- if gt (len $page.Content) 0 -}}
+ {{- if not (in ($.Scratch.Get "urlsAdded") $page.Permalink) -}}
+ {{- $pageData := (dict
+ "title" $page.Title
+ "href" $page.Permalink
+ "tags" (delimit ($page.Params.tags | default slice) " ; ")
+ "categories" (delimit ($page.Params.categories | default slice) " ; ")
+ "content" $page.Plain
+ ) -}}
+ {{- $.Scratch.Add "pagesIndex" $pageData -}}
+ {{- $.Scratch.Add "urlsAdded" $page.Permalink -}}
+ {{- end -}}
+ {{- end -}}
+{{- end -}}
+
+{{- $.Scratch.Get "pagesIndex" | jsonify -}}