From b0dfb769d18fae502066b09abf17dacdbc6519f3 Mon Sep 17 00:00:00 2001 From: panr Date: Fri, 25 Jan 2019 10:20:52 +0100 Subject: [PATCH] Add contentTypeName to config --- README.md | 2 ++ layouts/_default/list.html | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b8c3716..a473751 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,8 @@ paginate = 5 [params] subtitle = "A simple theme for Hugo" + # dir name for your list content + contentTypeName = "posts" # "light" or "dark" defaultTheme = "dark" diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 4ceeb47..74e2885 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,6 +1,9 @@ {{ define "main" }}
- {{ $paginator := .Paginate (where .Data.Pages "Type" "post") }} + {{ $isntDefault := not (or (eq (trim .Site.Params.contentTypeName " ") "posts") (eq (trim .Site.Params.contentTypeName " ") "")) }} + {{ $contentTypeName := cond $isntDefault (string .Site.Params.contentTypeName) "posts" }} + {{ $paginator := .Paginate (where .Data.Pages "Type" $contentTypeName) }} + {{ range $paginator.Pages }}

{{ .Title | markdownify }}