Add contentTypeName to config

This commit is contained in:
panr 2019-01-25 10:20:52 +01:00
parent cbc1b8f545
commit c9f7c5b4d2
2 changed files with 6 additions and 1 deletions

View File

@ -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"

View File

@ -1,6 +1,9 @@
{{ define "main" }}
<div class="posts">
{{ $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 }}
<div class="post on-list">
<h1 class="post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>