Skip to content

Commit 556ace0

Browse files
committed
Show only one year when copyright year range is a single year
1 parent e7b9136 commit 556ace0

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

layouts/_partials/footer/copyright.html

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
{{ $page := .Page -}}
22
{{ with .Site.Params.copyright -}}
3-
{{ $fromYear := "" -}}
4-
{{ $toYear := "" -}}
3+
{{ $yearDisplay := "" -}}
54
{{ $authors := "" -}}
65
{{ if reflect.IsMap . -}}
7-
{{ $fromYear = .from_year -}}
8-
{{ $toYear = .to_year -}}
6+
{{ $to := .to_year | default now.Year -}}
7+
{{ $yearDisplay = $to -}}
8+
{{ with .from_year -}}
9+
{{ if ne (string .) (string $to) -}}
10+
{{ $yearDisplay = printf "%v–%v" . $to -}}
11+
{{ end -}}
12+
{{ end -}}
913
{{ $authors = .authors -}}
1014
{{ else -}}
1115
{{ $authors = . -}}
1216
{{ end -}}
1317

1418
<span class="td-footer__copyright">&copy;
15-
{{ with $fromYear -}}
16-
{{ . }}&ndash;
17-
{{- end -}}
18-
{{ $toYear | default now.Year }}
19+
{{ $yearDisplay }}
1920
<span class="td-footer__authors">
2021
{{- $authors
2122
| default (printf "%s Authors" ($.Site.Title | default "Site"))

0 commit comments

Comments
 (0)