mirror of https://github.com/lxndrblz/anatole.git

Alexander Bilz
05.28.2021 e663d3981f4e2b198427202f556b9692f4279cd6
Merge pull request #107 from ivangjxyz/date-improvements

Date format parametrization
6 files modified
32 ■■■■ changed files
README.md 9 ●●●●● patch | view | raw | blame | history
assets/css/style.css 3 ●●●● patch | view | raw | blame | history
exampleSite/config.toml 5 ●●●● patch | view | raw | blame | history
layouts/_default/list.html 5 ●●●● patch | view | raw | blame | history
layouts/_default/single.html 5 ●●●● patch | view | raw | blame | history
layouts/index.html 5 ●●●● patch | view | raw | blame | history
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
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 */
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/"
  url = "/contact/"
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>
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>
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"