Skip to content

Commit 96cbabb

Browse files
committed
do not highlight the current page if there is only one page
1 parent b7f5b8e commit 96cbabb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

templates/base/paginate.tmpl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
{{$paginationLink := $.Link}}
33
{{if eq $paginationLink AppSubUrl}}{{$paginationLink = print $paginationLink "/"}}{{end}}
44
{{with .Page.Paginater}}
5-
{{if .TotalPages}}
6-
{{$showFirstLast := gt .TotalPages 0}}
5+
{{if or (eq .TotalPages -1) (gt .TotalPages 1)}}
6+
{{$showFirstLast := gt .TotalPages 1}}
77
<div class="center page buttons">
88
<div class="ui borderless pagination menu">
99
{{if $showFirstLast}}
@@ -17,11 +17,14 @@
1717
{{svg "octicon-chevron-left" 16 "tw-mr-1"}}
1818
<span class="navigation_label">{{ctx.Locale.Tr "repo.issues.previous"}}</span>
1919
</a>
20-
{{range .Pages}}
20+
{{$pages := .Pages}}
21+
{{$pagesLen := len $pages}}
22+
{{range $pages}}
2123
{{if eq .Num -1}}
2224
<a class="disabled item">...</a>
2325
{{else}}
24-
<a class="{{if .IsCurrent}}active {{end}}item" {{if not .IsCurrent}}href="{{$paginationLink}}?page={{.Num}}{{if $paginationParams}}&{{$paginationParams}}{{end}}"{{end}}>{{.Num}}</a>
26+
{{/* do not highlight the current page if there is only one page */}}
27+
<a class="{{if and .IsCurrent (gt $pagesLen 1)}}active {{end}}item" {{if not .IsCurrent}}href="{{$paginationLink}}?page={{.Num}}{{if $paginationParams}}&{{$paginationParams}}{{end}}"{{end}}>{{.Num}}</a>
2528
{{end}}
2629
{{end}}
2730
<a class="{{if not .HasNext}}disabled{{end}} item navigation" {{if .HasNext}}href="{{$paginationLink}}?page={{.Next}}{{if $paginationParams}}&{{$paginationParams}}{{end}}"{{end}}>

0 commit comments

Comments
 (0)