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

Peter Kleiweg
13.52.2022 c097ab90ab82e257d961b4122e690d25aeb1f6ea
feat: localized dates (#373)

Adds localized dates to the theme.

Requires Hugo version 0.87.0v or above.
4 files modified
39 ■■■■■ changed files
exampleSite/config/_default/config.toml 3 ●●●●● patch | view | raw | blame | history
layouts/_default/list.html 12 ●●●●● patch | view | raw | blame | history
layouts/_default/single.html 12 ●●●●● patch | view | raw | blame | history
layouts/index.html 12 ●●●●● patch | view | raw | blame | history
exampleSite/config/_default/config.toml
@@ -23,6 +23,9 @@
pygmentsCodeFences = true
pygmentsCodefencesGuessSyntax = true
# Localized dates requires Hugo version 0.87.0
localizedDates = false
[markup]
    [markup.goldmark]
        [markup.goldmark.renderer]
layouts/_default/list.html
@@ -16,12 +16,24 @@
            <a class="archive__list-title" href="{{ .RelPermalink }}" title="{{ .Title }}">{{ .Title }}</a>
            <div class="archive__list-date">
              {{ if isset .Site.Params "listdateformat" }}
                {{ if .Site.Params.localizedDates }}
                  {{ time.Format .Site.Params.listDateFormat .Date }}
                {{ else }}
                {{ .Date.Format .Site.Params.listDateFormat }}
                {{ end }}
              {{ else }}
                {{ if .Site.Params.localizedDates }}
                  {{ time.Format "Jan 2" .Date }}
                {{ else }}
                {{ .Date.Format "Jan 2" }}
                {{ end }}
              {{ end }}
            </div>
layouts/_default/single.html
@@ -22,12 +22,24 @@
            <em class="fas fa-calendar-day post__meta-icon"></em>
            <span class="post__meta-text"
              >{{ if isset .Site.Params "singledateformat" }}
                {{ if .Site.Params.localizedDates }}
                  {{ time.Format .Site.Params.singleDateFormat .Date }}
                {{ else }}
                {{ .Date.Format .Site.Params.singleDateFormat }}
                {{ end }}
              {{ else }}
                {{ if .Site.Params.localizedDates }}
                  {{ time.Format "Mon, Jan 2, 2006" .Date }}
                {{ else }}
                {{ .Date.Format "Mon, Jan 2, 2006" }}
                {{ end }}
              {{ end }}
            </span>
layouts/index.html
@@ -77,12 +77,24 @@
        <em class="fas fa-calendar-day"></em>
        <span class="post__footer-date"
          >{{ if isset .Site.Params "indexdateformat" }}
            {{ if .Site.Params.localizedDates }}
              {{ time.Format .Site.Params.indexDateFormat .Date }}
            {{ else }}
            {{ .Date.Format .Site.Params.indexDateFormat }}
            {{ end }}
          {{ else }}
            {{ if .Site.Params.localizedDates }}
              {{ time.Format "Mon, Jan 2, 2006" .Date }}
            {{ else }}
            {{ .Date.Format "Mon, Jan 2, 2006" }}
            {{ end }}
          {{ end }}</span
        >