Skip to content

Commit

Permalink
Merge pull request #34 from sikatikenmogne/feature/pagination-highlig…
Browse files Browse the repository at this point in the history
…hting

Add current page highlighting on the pagination component
  • Loading branch information
rakici authored Aug 22, 2024
2 parents 77aae1a + 8de1558 commit 7610ee6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/helpers/handlebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ export const repoName = (v1: string): string => {
const part: Array<string> = v1.split('/');
return `${part[3]}/${part[4]}`;
};

export const addClassIfEqual = (v1: number, v2: number, extra: number, v3: string): string => {
return v1 === (v2+extra) ? v3 : '';
};
4 changes: 2 additions & 2 deletions src/views/partials/pagination.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
<li class="disabled page-item"><a class="page-link">...</a></li>
{{/if}}
{{#each (displayPagesNumber interval current pages)}}
{{#if (ifEqual . current 0)}}
{{#if (ifEqual . @root.current 0)}}
<li class="active page-item"><a class="page-link">{{ . }}</a></li>
{{else}}
{{#if @root.hasParams}}
{{#if (contains @root.fullUrl "page")}}
<li class="page-item"><a href="{{{constructUrl @root.fullUrl .}}}" class="page-link">{{ . }}</a></li>
<li class="page-item {{{addClassIfEqual . @root.current 0 'active'}}}"><a href="{{{constructUrl @root.fullUrl .}}}" class="page-link">{{ . }}</a></li>
{{else}}
<li class="page-item"><a href="{{@root.fullUrl}}&page={{.}}" class="page-link">{{ . }}</a></li>
{{/if}}
Expand Down

0 comments on commit 7610ee6

Please sign in to comment.