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
53 ■■■■ changed files
exampleSite/config/_default/config.toml 5 ●●●● patch | view | raw | blame | history
layouts/_default/list.html 16 ●●●● patch | view | raw | blame | history
layouts/_default/single.html 16 ●●●● patch | view | raw | blame | history
layouts/index.html 16 ●●●● 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]
@@ -42,4 +45,4 @@
  weight = 100
[[related.indices]]
  name = 'tags'
  weight = 80
  weight = 80
layouts/_default/list.html
@@ -16,11 +16,23 @@
            <a class="archive__list-title" href="{{ .RelPermalink }}" title="{{ .Title }}">{{ .Title }}</a>
            <div class="archive__list-date">
              {{ if isset .Site.Params "listdateformat" }}
                {{ .Date.Format .Site.Params.listDateFormat }}
                {{ if .Site.Params.localizedDates }}
                  {{ time.Format .Site.Params.listDateFormat .Date }}
                {{ else }}
                  {{ .Date.Format .Site.Params.listDateFormat }}
                {{ end }}
              {{ else }}
                {{ .Date.Format "Jan 2" }}
                {{ if .Site.Params.localizedDates }}
                  {{ time.Format "Jan 2" .Date }}
                {{ else }}
                  {{ .Date.Format "Jan 2" }}
                {{ end }}
              {{ end }}
layouts/_default/single.html
@@ -22,11 +22,23 @@
            <em class="fas fa-calendar-day post__meta-icon"></em>
            <span class="post__meta-text"
              >{{ if isset .Site.Params "singledateformat" }}
                {{ .Date.Format .Site.Params.singleDateFormat }}
                {{ if .Site.Params.localizedDates }}
                  {{ time.Format .Site.Params.singleDateFormat .Date }}
                {{ else }}
                  {{ .Date.Format .Site.Params.singleDateFormat }}
                {{ end }}
              {{ else }}
                {{ .Date.Format "Mon, Jan 2, 2006" }}
                {{ if .Site.Params.localizedDates }}
                  {{ time.Format "Mon, Jan 2, 2006" .Date }}
                {{ else }}
                  {{ .Date.Format "Mon, Jan 2, 2006" }}
                {{ end }}
              {{ end }}
layouts/index.html
@@ -77,11 +77,23 @@
        <em class="fas fa-calendar-day"></em>
        <span class="post__footer-date"
          >{{ if isset .Site.Params "indexdateformat" }}
            {{ .Date.Format .Site.Params.indexDateFormat }}
            {{ if .Site.Params.localizedDates }}
              {{ time.Format .Site.Params.indexDateFormat .Date }}
            {{ else }}
              {{ .Date.Format .Site.Params.indexDateFormat }}
            {{ end }}
          {{ else }}
            {{ .Date.Format "Mon, Jan 2, 2006" }}
            {{ if .Site.Params.localizedDates }}
              {{ time.Format "Mon, Jan 2, 2006" .Date }}
            {{ else }}
              {{ .Date.Format "Mon, Jan 2, 2006" }}
            {{ end }}
          {{ end }}</span