From 7a69ffcdf87a5f55cab30b61c44139d94016498e Mon Sep 17 00:00:00 2001 From: panr Date: Mon, 27 Jan 2020 18:29:31 +0100 Subject: [PATCH] Small fixes to lastMod feature --- README.md | 3 ++- layouts/_default/list.html | 6 +++--- layouts/_default/single.html | 10 +++++----- layouts/partials/lastmod.html | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 435fdbc..0fe0593 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ This theme is pretty basic and covers all of the essentials. All you have to do - [How to start](#how-to-start) - [How to configure](#how-to-configure) - [How to add a cover image to your posts](#how-to-add-a-cover-image-to-your-posts) +- [How to display the Last Modified Date in your posts](#how-to-display-the-last-modified-date-in-your-posts) - [Add-ons](#add-ons) - [How to run your site](#how-to-run-your-site) - [How to edit the theme](#how-to-edit-the-theme) @@ -137,7 +138,7 @@ Adding a cover image to your post is simple and there are two options when you e * Use `cover = "img.jpg"` and `useRelativeCover = true` to link the image relative to the blog post folder * Resulting in `https://www.yourpage.com/posts/blog-entry-xy/img.jpg` -# How to display the Last Modified Date in your posts +## How to display the Last Modified Date in your posts Add `lastModDisplay = "[your display text]"` to `config.toml` to enable last modified date on your posts. Note - an empty string value `""` does not display anything. diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 57d3988..2f76a56 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -17,8 +17,8 @@ {{ .Date.Format ($.Site.Params.DateFormatList | default "2006-01-02") }} - - {{ if $.Site.Params.LastModDisplay}} + + {{ if $.Site.Params.LastModDisplay }} {{ partial "lastmod.html" . }} {{ end }} {{ end }} @@ -58,4 +58,4 @@ {{ end }} {{ partial "pagination.html" . }} -{{ end }} \ No newline at end of file +{{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index ab65bf7..b58ef9a 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -9,9 +9,9 @@ {{ .Date.Format ($.Site.Params.DateFormatSingle | default "2006-01-02") }} - + {{ if eq .Type $contentTypeName }} - {{ if $.Site.Params.LastModDisplay}} + {{ if $.Site.Params.LastModDisplay }} {{ partial "lastmod.html" . }} {{ end }} {{ end }} @@ -70,13 +70,13 @@ {{ end }} {{ end }} - + {{ if not (eq .Params.Comments "false") }} {{ if or (eq .Type $.Site.Params.contentTypeName) (.Params.Comments) }} {{ partial "comments.html" . }} {{ end }} {{ end }} - + -{{ end }} \ No newline at end of file +{{ end }} diff --git a/layouts/partials/lastmod.html b/layouts/partials/lastmod.html index a9b9693..6aa3735 100644 --- a/layouts/partials/lastmod.html +++ b/layouts/partials/lastmod.html @@ -1,4 +1,4 @@ -{{$hourInSec := 3600}} +{{ $hourInSec := 3600 }} {{ if gt .Lastmod (add (time .Date).Unix $hourInSec) }} {{ with .Lastmod }} @@ -6,4 +6,4 @@ ({{ $.Site.Params.LastModDisplay }} {{ .Format ($.Site.Params.DateFormatSingle | default "2006-01-02") }}) {{ end }} -{{ end }} \ No newline at end of file +{{ end }}