Use custom URL if author starts with `https://` (#125)

Resolves #124 and would allow for something like `author_domain: github.com` if the author instead has a profile there.

Co-authored-by: jolheiser <john.olheiser@gmail.com>
Reviewed-on: https://gitea.com/gitea/theme/pulls/125
Reviewed-by: delvh <dev.lh@web.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john+gitea@jolheiser.com>
Co-committed-by: John Olheiser <john+gitea@jolheiser.com>
This commit is contained in:
John Olheiser 2023-03-10 09:58:40 +08:00 committed by Lunny Xiao
parent 0de5dfc0fe
commit 5e7d82b6cd
2 changed files with 8 additions and 8 deletions

View File

@ -15,13 +15,13 @@
{{ $s.Set "len" (len .Params.authors) }}
{{ $s.Add "len" -1 }}
{{ range $idx, $author := .Params.authors -}}
<a class="author" href="https://gitea.com/{{ $author | default $.Site.Params.author }}">
{{ $author | default $.Site.Params.author }}
<a class="author" href="{{ if hasPrefix $author "https://" }}{{ $author }}{{ else }}https://gitea.com/{{ $author }}{{ end }}">
{{ path.BaseName $author }}
</a>{{ if ne $idx ($s.Get "len") }}, {{end}}
{{- end }}
{{ else }}
<a class="author" href="https://gitea.com/{{ .Params.author | default .Site.Params.author }}">
{{ .Params.author | default .Site.Params.author }}
<a class="author" href="{{ if hasPrefix .Params.author "https://" }}{{ .Params.author }}{{ else }}https://gitea.com/{{ .Params.author }}{{ end }}">
{{ path.BaseName (.Params.author | default .Site.Params.author) }}
</a>
{{ end }}
</p>

View File

@ -18,13 +18,13 @@
{{ $s.Set "len" (len .Params.authors) }}
{{ $s.Add "len" -1 }}
{{ range $idx, $author := .Params.authors -}}
<a class="author" href="https://gitea.com/{{ $author | default $.Site.Params.author }}">
{{ $author | default $.Site.Params.author }}
<a class="author" href="{{ if hasPrefix $author "https://" }}{{ $author }}{{ else }}https://gitea.com/{{ $author }}{{ end }}">
{{ path.BaseName $author }}
</a>{{ if ne $idx ($s.Get "len") }}, {{end}}
{{- end }}
{{ else }}
<a class="author" href="https://gitea.com/{{ .Params.author | default .Site.Params.author }}">
{{ .Params.author | default .Site.Params.author }}
<a class="author" href="{{ if hasPrefix .Params.author "https://" }}{{ .Params.author }}{{ else }}https://gitea.com/{{ .Params.author }}{{ end }}">
{{ path.BaseName (.Params.author | default .Site.Params.author) }}
</a>
{{ end }}
</b>