From 7227a66c0427213ce61e0cc59806f4a166f01347 Mon Sep 17 00:00:00 2001 From: Curtis Timson Date: Mon, 4 Jun 2018 18:47:39 +0100 Subject: Add default values for post settings --- exampleSite/config-prod.toml | 13 +++++++++---- exampleSite/config.toml | 9 +++++---- layouts/index.html | 15 +++++++++------ package.json | 2 +- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/exampleSite/config-prod.toml b/exampleSite/config-prod.toml index 3888702..f7b7c87 100644 --- a/exampleSite/config-prod.toml +++ b/exampleSite/config-prod.toml @@ -3,10 +3,15 @@ title = "Massively" baseURL = "https://hugo-theme-massively.netlify.com/" theme = "../.." -[params.posts] - foldername = "post" - pagesize = "6" - featuredpost = "true" +# [params] + # set below parameter to define a favicon + # favicon = "favicon.ico" + +# Below parameters can be set to override default post settings +# [params.posts] +# foldername = "post" +# pagesize = "6" +# featuredpost = "true" [params.settings] googleanalytics = "UA-113904582-4" diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 4b20b74..4e4cbd0 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -7,10 +7,11 @@ theme = "../.." # set below parameter to define a favicon # favicon = "favicon.ico" -[params.posts] - foldername = "post" - pagesize = "6" - featuredpost = "true" +# Below parameters can be set to override default post settings +# [params.posts] +# foldername = "post" +# pagesize = "6" +# featuredpost = "true" [params.settings] googleanalytics = "UA-113904582-3" diff --git a/layouts/index.html b/layouts/index.html index 237d062..b45fb1c 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,21 +1,24 @@ {{ partial "htmlhead" . }} - {{ $posts := where .Data.Pages "Type" .Site.Params.Posts.foldername }} - {{ $firstPost := first 1 $posts }} + {{ $postsFoldername := .Site.Params.Posts.foldername | default "post" }} + {{ $postsPageSize := .Site.Params.Posts.pagesize | default 6 }} + {{ $postsFeaturedPost := .Site.Params.Posts.featuredpost | default "true" }} + {{ $posts := where .Data.Pages "Type" $postsFoldername }} + {{ $firstPost := first 1 $posts }} - {{ if and (eq .Site.Params.Posts.featuredpost "true") (gt (len $posts) 1) }} + {{ if and (eq $postsFeaturedPost "true") (gt (len $posts) 1) }} {{ .Scratch.Set "postsForPaging" (after 1 $posts) }} {{ else }} {{ .Scratch.Set "postsForPaging" $posts }} {{ end }} {{ $postsForPaging := .Scratch.Get "postsForPaging" }} - {{ $postsPaging := .Paginate $postsForPaging .Site.Params.Posts.pagesize }} + {{ $postsPaging := .Paginate $postsForPaging $postsPageSize }} -
+
{{ if eq $postsPaging.PageNumber 1 }} {{ partial "intro.html" . }} @@ -27,7 +30,7 @@
- {{ if eq .Site.Params.Posts.featuredpost "true" }} + {{ if eq $postsFeaturedPost "true" }} {{ partial "posts/featured.html" (dict "firstpost" $firstPost "siteData" (index .Site.Data .Site.Language.Lang)) }} {{ end }} {{ partial "posts/list.html" (dict "posts" $postsPaging "siteData" (index .Site.Data .Site.Language.Lang)) }} diff --git a/package.json b/package.json index 9ce7545..9a689ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hugo-theme-massively", - "version": "2.2.0", + "version": "2.2.1", "description": "HTML5 UP theme Massively for Hugo", "main": "index.js", "scripts": { -- cgit v1.2.3