Skip to content

Commit b037403

Browse files
committed
Show only one year when copyright year range is a single year
1 parent d1fd540 commit b037403

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

layouts/partials/footer/copyright.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{{ $page := .Page -}}
22
{{ with .Site.Params.copyright -}}
3-
{{ $fromYear := "" -}}
4-
{{ $toYear := "" -}}
3+
{{ $yearRange := slice -}}
54
{{ $authors := "" -}}
65
{{ if reflect.IsMap . -}}
7-
{{ $fromYear = .from_year -}}
8-
{{ $toYear = .to_year -}}
6+
{{ with .from_year -}}
7+
{{ $yearRange = slice . -}}
8+
{{ end -}}
9+
{{ $yearRange = $yearRange
10+
| append (.to_year | default now.Year)
11+
| uniq -}}
912
{{ $authors = .authors -}}
1013
{{ else -}}
1114
{{ $authors = . -}}
1215
{{ end -}}
1316

1417
<span class="td-footer__copyright">&copy;
15-
{{ with $fromYear -}}
16-
{{ . }}&ndash;
17-
{{- end -}}
18-
{{ $toYear | default now.Year }}
18+
{{ delimit $yearRange "–" }}
1919
<span class="td-footer__authors">
2020
{{- $authors
2121
| default (printf "%s Authors" ($.Site.Title | default "Site"))

0 commit comments

Comments
 (0)