Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions COMMUNITY-FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ eg:
- **Support for beautiful *KaTeX* formulae** ([amtoine/hugo-theme-terminal-katex](https://github.com/amtoine/hugo-theme-terminal-katex))
- SHORT DESCRIPTION
- Antoine Stevan ([@amtoine](https://github.com/amtoine)), software engineer into open source

- **Configurable timestamping for posts** ([KatieTheDev/hugo-theme-terminal](https://github.com/KatieTheDev/hugo-theme-terminal))
- Allows for configuring timestamping, not just datestamping
- Works with last modification dates as well
- KatieTheDev ([@KatieTheDev](https://github.com/KatieTheDev))
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,20 @@ paginate = 5
# can be overridden in a page's front-matter
# TocTitle = "Table of Contents" # default

# Set date/time format for posts
# This will impact the date/time displayed on
# index.html, the posts list page, and on posts themselves
# This value can also be configured per-post on front matter
# If you have any issues with the timezone rendering differently
# than you expected, please ensure your timezone is correctly set
# on your server.
# This value can be customized according to Hugo documentation:
# https://gohugo.io/functions/time/format/
# Default value (no changes needed):
# dateFormat = "2006-01-02"
# Example format, with date, time, and timezone abbreviation:
# dateFormat = "2006-01-02 3:04:06 PM MST"


[params.twitter]
# set Twitter handles for Twitter cards
Expand Down
1 change: 1 addition & 0 deletions archetypes/posts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
+++
title = "{{ replace .TranslationBaseName "-" " " | title }}"
date = "{{ .Date }}"
#dateFormat = "2006-01-02" # This value can be configured for per-post date formatting
author = ""
authorTwitter = "" #do not include @
cover = ""
Expand Down
11 changes: 10 additions & 1 deletion layouts/_default/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ <h2 class="post-title">
<div class="post-meta">
{{- if .Date -}}
<time class="post-date">
{{- .Date.Format "2006-01-02" -}}
{{- $date := .Date | time -}}
{{- with .Params.dateFormat -}}
{{- $date | time.Format . -}}
{{- else -}}
{{- with .Site.Params.dateFormat -}}
{{- $date | time.Format . -}}
{{- else -}}
{{- $date | time.Format "2006-01-02" -}}
{{- end -}}
{{- end -}}
</time>
{{- end -}}
{{- with .Params.Author -}}
Expand Down
11 changes: 10 additions & 1 deletion layouts/_default/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ <h2 class="post-title">
<div class="post-meta">
{{- if .Date -}}
<time class="post-date">
{{- .Date.Format "2006-01-02" -}}
{{- $date := .Date | time -}}
{{- with .Params.dateFormat -}}
{{- $date | time.Formatt . -}}
{{- else -}}
{{- with .Site.Params.dateFormat -}}
{{- $date | time.Format . -}}
{{- else -}}
{{- $date | time.Format "2006-01-02" -}}
{{- end -}}
{{- end -}}
</time>
{{- end -}}
{{- with .Params.Author -}}
Expand Down
22 changes: 20 additions & 2 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,27 @@ <h1 class="post-title">
<div class="post-meta">
{{- if .Date -}}
<time class="post-date">
{{- .Date.Format "2006-01-02" -}}
{{- $date := .Date | time -}}
{{- with .Params.dateFormat -}}
{{- $date | time.Format . -}}
{{- else -}}
{{- with .Site.Params.dateFormat -}}
{{- $date | time.Format . -}}
{{- else -}}
{{- $date | time.Format "2006-01-02" -}}
{{- end -}}
{{- end -}}
{{- if $.Site.Params.showLastUpdated -}}
[{{- or $.Site.Params.updatedDatePrefix "Updated" -}} :: {{- .Lastmod.Format "2006-01-02" -}}]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KatieTheDev Looks good and works well 💪 But I found that you removed the [{{- or $.Site.Params.updatedDatePrefix "Updated" -}} :: ... string from the brackets. Was it intentional?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's a bug, after the fix we will merge it :)

{{- $lastmod := .Lastmod | time -}}
{{- with .Params.dateFormat -}}
&nbsp;[{{- $lastmod | time.Format . -}}]
{{- else -}}
{{- with .Site.Params.dateFormat -}}
&nbsp;[{{- $lastmod | time.Format . -}}]
{{- else -}}
&nbsp;[{{- $lastmod | time.Format "2006-01-02" -}}]
{{- end -}}
{{- end -}}
{{- end -}}
</time>
{{- end -}}
Expand Down