From 5805195fe8399a99ddb6a944704be230a7a6f116 Mon Sep 17 00:00:00 2001 From: darcy Date: Mon, 13 Dec 2021 22:33:50 +0800 Subject: feat: add last modified time to posts add a new param: hideModifiedDate. If set to false, the last modified time of post is displayed.A site global configuration is also added, enableGitInfo. If set to true, the last modified time will get from git commits. More can see this: https://gohugo.io/getting-started/configuration/#enablegitinfo --- exampleSite/config.toml | 6 ++++++ layouts/_default/li.html | 3 +++ layouts/partials/modified_date.html | 4 ++++ 3 files changed, 13 insertions(+) create mode 100644 layouts/partials/modified_date.html diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 3f41391..49fba7c 100755 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -7,10 +7,16 @@ copyright = "© Copyright notice" # Google Analytics API key. googleAnalytics = "Your Google Analytics tracking id" +# enable get info from git commits, such as file modification time. +# so we don't have to manually update it. +enableGitInfo = true + [params] paginate = 10 # Hide the date on posts # hideDate = true + # Hide last modified date on posts + # hideModifiedDate = true # Hide the word count on posts and in the posts list # hideWordCount = true # Hide the reading time on posts and in the posts list diff --git a/layouts/_default/li.html b/layouts/_default/li.html index 7e3c953..de23d6c 100755 --- a/layouts/_default/li.html +++ b/layouts/_default/li.html @@ -3,6 +3,9 @@

{{ .Title }}

{{ partial "timestamp.html" . }} + {{ if not (.Param "hideModifiedDate") }} + | {{ partial "modified_date.html" . }} + {{ end }} {{ if not (.Param "hideWordCount") }} | {{ partial "word_count.html" . }} {{ end }} diff --git a/layouts/partials/modified_date.html b/layouts/partials/modified_date.html new file mode 100644 index 0000000..76802a9 --- /dev/null +++ b/layouts/partials/modified_date.html @@ -0,0 +1,4 @@ +Updated on + -- cgit v1.2.3