From e663d3981f4e2b198427202f556b9692f4279cd6 Mon Sep 17 00:00:00 2001
From: Alexander Bilz <mail@alexbilz.com>
Date: Tue, 05 Jan 2021 10:28:05 +0000
Subject: [PATCH] Merge pull request #107 from ivangjxyz/date-improvements
---
exampleSite/config.toml | 5 ++++-
layouts/_default/list.html | 5 ++++-
layouts/_default/single.html | 5 ++++-
layouts/index.html | 5 ++++-
assets/css/style.css | 3 +--
README.md | 9 +++++++++
6 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 39b8e3c..621fe74 100644
--- a/README.md
+++ b/README.md
@@ -129,6 +129,15 @@
doNotLoadAnimations = true # Animations are loaded by default
```
+### Control the date Format
+You can change the default date formating for the `list.html`, the `single.html` and the `index.html`. Simply configure the matching parameters.
+```toml
+[params]
+singleDateFormat = "Mon, Jan 2, 2006"
+indexDateFormat = "Mon, Jan 2, 2006"
+listDateFormat = "Jan 2"
+```
+
### Have a static page as a home page
If you prefer having a static page as your home page rather than a listing of the latest posts, then make sure you leave the `mainSections` parameter blank:
```toml
diff --git a/assets/css/style.css b/assets/css/style.css
index 693b4f3..8b2118c 100644
--- a/assets/css/style.css
+++ b/assets/css/style.css
@@ -887,7 +887,6 @@
display: block;
flex-grow: 0;
flex-shrink: 0;
- display: block;
line-height: 2.5;
padding: .5rem .75rem;
position: relative;
@@ -1069,4 +1068,4 @@
border: 1px solid var(--form-button-hover-border-color);
}
-/* (CONTACT) FORM END */
+/* (CONTACT) FORM END */
\ No newline at end of file
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 3195051..4782677 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -37,6 +37,9 @@
#contactFormAction = "https://formspree.io/f/your-form-hash-here"
# Google Site Verify
#googleSiteVerify = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
+# indexDateFormat = "Mon, Jan 2, 2006"
+# listDateFormat = "Jan 2"
+# singleDateFormat = "Mon, Jan 2, 2006"
[params.simpleAnalytics]
# enable = true
@@ -95,4 +98,4 @@
name = "Contact"
weight = 400
identifier = "contact"
- url = "/contact/"
\ No newline at end of file
+ url = "/contact/"
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
index 9a8254c..cad95c8 100644
--- a/layouts/_default/list.html
+++ b/layouts/_default/list.html
@@ -7,7 +7,10 @@
<ul class="listing">
<div class="listing-item">
<div class="listing-post"><a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Title }}</a>
- <div class="post-time"><span class="date">{{.Date.Format "Jan 2" }}</span></div>
+ <div class="post-time"><span class="date">{{ if isset .Site.Params "listdateformat" }}
+ {{ .Date.Format .Site.Params.listDateFormat }}
+ {{ else }} {{.Date.Format "Jan 2"}}
+ {{ end }}</span></div>
</div>
</div>
</ul>
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index 352a37d..08a68ed 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -6,7 +6,10 @@
{{ if eq .Type "post"}}
<div class="info">
<em class="fas fa-calendar-day"></em>
- <span class="date">{{ .Date.Format "Mon, Jan 2, 2006" }}</span>
+ <span class="date">{{ if isset .Site.Params "singledateformat" }}
+ {{ .Date.Format .Site.Params.singleDateFormat }}
+ {{ else }} {{.Date.Format "Mon, Jan 2, 2006"}}
+ {{ end }}</span>
<em class="fas fa-stopwatch"></em>
<span class="reading-time">{{ i18n "reading_time" .ReadingTime }}</span>
</div>
diff --git a/layouts/index.html b/layouts/index.html
index 7b91878..c5ec3a3 100644
--- a/layouts/index.html
+++ b/layouts/index.html
@@ -24,7 +24,10 @@
<div class="post-footer">
<div class="meta">
<div class="info"><em class="fas fa-calendar-day"></em><span
- class="date">{{ .Date.Format "Mon, Jan 2, 2006" }}</span>
+ class="date">{{ if isset .Site.Params "indexdateformat" }}
+ {{ .Date.Format .Site.Params.indexDateFormat }}
+ {{ else }} {{.Date.Format "Mon, Jan 2, 2006"}}
+ {{ end }}</span>
{{ with .Params.tags }}
{{- range $index, $el := . -}}
<a class="tag"
--
Gitblit v1.10.0