next-prev-navigator.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. {{ $curPage := . }}
  2. {{ $prevPage := "" }}
  3. {{ $nextPage := "" }}
  4. <!-- List all the pages. It uses the sidebar menu to discover the page order. -->
  5. {{ $pages := slice }}
  6. {{ if isset site.Menus "sidebar" }}
  7. {{ $pages = partial "helpers/get-pages.html" site.Menus.sidebar }}
  8. {{ end }}
  9. <!-- Now, find the current page index in the pages list. Then, find previous page and next page. -->
  10. {{ $idx := 0 }}
  11. {{ range $pages }}
  12. {{ if eq .RelPermalink $curPage.RelPermalink }}
  13. {{ $prevPage = index $pages (sub $idx 1) }}
  14. {{ $nextPage = index $pages (add $idx 1) }}
  15. {{ end }}
  16. {{ $idx = add $idx 1 }}
  17. {{ end }}
  18. <div class="row next-prev-navigator">
  19. {{ if $prevPage }}
  20. <div class="col-md-6 previous-article">
  21. <a href="{{ $prevPage.RelPermalink }}" title="{{ $prevPage.Title }}" class="btn filled-button">
  22. <div><i class="fas fa-chevron-circle-left"></i> {{ i18n "prev" }}</div>
  23. <div class="next-prev-text">{{ $prevPage.Title }}</div>
  24. </a>
  25. </div>
  26. {{ end }}
  27. {{ if $nextPage }}
  28. {{ $columnWidth:="col-md-12" }}
  29. {{ if $prevPage }}
  30. {{ $columnWidth = "col-md-6" }}
  31. {{ end}}
  32. <div class="{{ $columnWidth }} next-article">
  33. <a href="{{ $nextPage.RelPermalink }}" title="{{ $nextPage.Title }}" class="btn filled-button">
  34. <div>{{ i18n "next" }} <i class="fas fa-chevron-circle-right"></i></div>
  35. <div class="next-prev-text">{{ $nextPage.Title }}</div>
  36. </a>
  37. </div>
  38. {{ end }}
  39. </div>