next-prev-navigator.html 1.4 KB

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