Skip to content

Commit

Permalink
Show only one year when copyright year range is a single year
Browse files Browse the repository at this point in the history
  • Loading branch information
tcrouch committed Oct 9, 2024
1 parent d1fd540 commit f7b69bc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions layouts/partials/footer/copyright.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{{ $page := .Page -}}
{{ with .Site.Params.copyright -}}
{{ $fromYear := "" -}}
{{ $toYear := "" -}}
{{ $yearRange := slice -}}
{{ $authors := "" -}}
{{ if reflect.IsMap . -}}
{{ $fromYear = .from_year -}}
{{ $toYear = .to_year -}}
{{ with .from_year -}}
{{ $yearRange = slice . -}}
{{ end -}}
{{ $yearRange = $yearRange
| append (.to_year | default now.Year)
| uniq -}}
{{ $authors = .authors -}}
{{ else -}}
{{ $authors = . -}}
{{ end -}}

<span class="td-footer__copyright">&copy;
{{ with $fromYear -}}
{{ . }}&ndash;
{{- end -}}
{{ $toYear | default now.Year }}
{{ delimit $yearRange "–" }}
<span class="td-footer__authors">
{{- $authors
| default (printf "%s Authors" ($.Site.Title | default "Site"))
Expand Down

0 comments on commit f7b69bc

Please sign in to comment.