diff options
author | James Elliott <james-d-elliott@users.noreply.github.com> | 2022-03-23 14:14:30 +0300 |
---|---|---|
committer | James Elliott <james-d-elliott@users.noreply.github.com> | 2022-03-23 14:14:30 +0300 |
commit | 525ba3c1d2009af50ab65ce9ff963085fdf02dbc (patch) | |
tree | b3f910ad871f0b3e0841e50afc95f8a6811a88a7 | |
parent | 29428c692e62cbad03dea54b14a12137ddf836c5 (diff) |
fix(layouts): use comma for more than 2 contributors
This makes the byline show commas on all but the last author of a blog post.
-rw-r--r-- | layouts/partials/main/blog-meta.html | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/layouts/partials/main/blog-meta.html b/layouts/partials/main/blog-meta.html index a9eb438..d3cc3b7 100644 --- a/layouts/partials/main/blog-meta.html +++ b/layouts/partials/main/blog-meta.html @@ -1 +1,2 @@ -<p><small>Posted {{ .PublishDate.Format "January 2, 2006" }} by {{ if .Params.contributors -}}{{ range $index, $contributor := .Params.contributors }}{{ if gt $index 0 }} and {{ end }}<a class="stretched-link position-relative" href="{{ "/contributors/" | relURL }}{{ . | urlize }}/">{{ . }}</a>{{ end -}}{{ end -}} ‐ <strong>{{ .ReadingTime -}} min read</strong></small><p>
\ No newline at end of file +{{ $last := sub (len .Params.contributors) 1 }} +<p><small>Posted {{ .PublishDate.Format "January 2, 2006" }} by {{ if .Params.contributors -}}{{ range $index, $contributor := .Params.contributors }}{{ if gt $index 0 }}{{ if eq $index $last }} and {{ else }}, {{ end }}{{ end }}<a class="stretched-link position-relative" href="{{ "/contributors/" | relURL }}{{ . | urlize }}/">{{ . }}</a>{{ end -}}{{ end -}} ‐ <strong>{{ .ReadingTime -}} min read</strong></small><p> |