Skip to content

Commit 2a532c6

Browse files
authored
Merge pull request #12 from Netcentric/repo-order
Fixes #9
2 parents 577607b + 36c71a3 commit 2a532c6

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

themes/influencer-hugo/layouts/index.html

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,35 +68,38 @@ <h2 class="text-lg">{{ .title | markdownify }}</h2>
6868

6969

7070
<div class="card-group">
71-
{{ range $index, $repo := (getJSON "https://api.github.com/orgs/Netcentric/repos") }}
71+
{{ $.Scratch.Set "$index" 0 }}
72+
{{ $repo := (getJSON "https://api.github.com/orgs/Netcentric/repos") }}
73+
{{ range sort $repo "stargazers_count" "desc"}}
74+
{{ $.Scratch.Set "$index" (add ($.Scratch.Get "$index") 1) }}
7275
<div class="card mr-4 mb-4 repo-card">
7376
<div class="card-body">
7477
<h3 class="h4 card-title repo-title">
75-
<a href="{{ $repo.html_url | safeURL }}" title="{{ $repo.full_name | markdownify }}" rel="noopener">
76-
{{ replace $repo.full_name "Netcentric/" "" | markdownify }}
78+
<a href="{{ .html_url | safeURL }}" title="{{ .full_name | markdownify }}" rel="noopener">
79+
{{ replace .full_name "Netcentric/" "" | markdownify }}
7780
</a>
7881
</h3>
79-
<p class="card-text">{{ $repo.description | markdownify }}</p>
82+
<p class="card-text">{{ .description | markdownify }}</p>
8083
</div>
8184
<div class="card-footer">
8285
<div class="d-flex">
8386
<span class="d-flex align-items-center mr-3">
8487
<img class="icon mr-2" alt="Star" src="/images/icons/star.svg" />
85-
<span class="d-inline-block">{{ $repo.stargazers_count }}</span>
88+
<span class="d-inline-block">{{ .stargazers_count }}</span>
8689
</span>
87-
{{ if gt $repo.forks_count 0 }}
90+
{{ if gt .forks_count 0 }}
8891
<span class="d-flex align-items-center">
8992
<img class="icon mr-2" alt="Github forks" src="/images/icons/github.svg" />
9093
<span>
91-
{{ $repo.forks_count }}
92-
{{ if gt $repo.forks_count 1 }}forks{{ else }}fork{{ end }}
94+
{{ .forks_count }}
95+
{{ if gt .forks_count 1 }}forks{{ else }}fork{{ end }}
9396
</span>
9497
</span>
9598
{{ end }}
9699
</div>
97100
</div>
98101
</div>
99-
{{ if eq (mod (add ($index) 1) 2) 0 }}
102+
{{ if eq (mod ($.Scratch.Get "$index") 2) 0 }}
100103
</div><div class="card-group">
101104
{{ end }}
102105
{{ end }}

0 commit comments

Comments
 (0)