Skip to content

Fix #1505 : updated contributors shortcode to use try and Value pattern for … #1506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions common-theme/layouts/_default/_markup/render-link.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
{{- with .Title -}}title="{{- . -}}"{{- end -}}
>{{- .Text | safeHTML -}}
</a>
{{- /* This is scarfed directly from Bep https://portable-hugo-links.netlify.app/
{{/* This is scarfed directly from Bep https://portable-hugo-links.netlify.app/
It allegedly makes a version of wikilinks that still works on GitHub
* [Rel Link](../p2.md)
* [Section Link](/section/p2.md)
* [Section Link With Anchor](/section/d1.md#anchor)
to replace the Hugo shortcode rel-ref
*/
-}}
*/}}
28 changes: 14 additions & 14 deletions common-theme/layouts/shortcodes/contributors.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
{{ $headers := partial "github-auth.html" }}

{{/* Let's go get our contributors list */}}
{{ with resources.GetRemote $api $headers }}
{{ with try (resources.GetRemote $api $headers) }}
{{ with .Err }}
{{ warnf "🏷️ No contributors: %s . Error: %s ." $api . }}
{{ else }}
{{ $contributors := .Value.Content | unmarshal }}
<ol class="c-contributors">
{{ range sort $contributors ".contributions" "desc" }}
<li class="c-contributor">
<h3 class="c-contributor__name">
<a class="c-contributor__link" href="{{ .html_url }}">{{ .login }}</a>
</h3>
<img class="c-contributor__avatar" src="{{ .avatar_url }}" alt="" />
</li>
{{ end }}
</ol>
{{ end }}

{{ $contributors := .Content | unmarshal }}
<ol class="c-contributors">
{{ range sort $contributors ".contributions" "desc" }}
<li class="c-contributor">
<h3 class="c-contributor__name">
<a class="c-contributor__link" href="{{ .html_url }}">{{ .login }}</a>
</h3>
<img class="c-contributor__avatar" src="{{ .avatar_url }}" alt="" />
</li>
{{ end }}
</ol>
{{ end }}
{{ end }}