Created
January 5, 2014 19:20
-
-
Save Darep/8272582 to your computer and use it in GitHub Desktop.
Old-school numbered pagination for middleman-blog – see http://i.imgur.com/oYa0Cfj.png
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if paginate && num_pages > 1 %> | |
<div class="pagination"> | |
<% if prev_page %> | |
<%= link_to '<i class="icon-arrow-left"></i> Prev', prev_page, class: 'prev page-numbers' %> | |
<% else %> | |
<span class="disabled"><i class="icon-arrow-left"></i> Prev</span> | |
<% end %> | |
<% for p in 1..num_pages %> | |
<% if p == page_number %> | |
<span class="page-numbers current"><%= p %></span> | |
<% elsif p == 1 %> | |
<%= link_to p, "/blog" %> | |
<% else %> | |
<%= link_to p, "/blog/page/#{p}" %> | |
<% end %> | |
<% end %> | |
<% if next_page %> | |
<%= link_to 'Next <i class="icon-arrow-right"></i>', next_page, class: 'next page-numbers' %> | |
<% else %> | |
<span class="disabled">Next <i class="icon-arrow-right"></i></span> | |
<% end %> | |
</div> | |
<% end %> |
TODO: add support for hiding extra pages. With over 10 pages, the pagination starts to get super weird and un-usable
Works for fixed prefixes. So the prefix needs to be hard-coded. For example,
/blog/<%= year %>/
/blog/<%= year %>/page/<%= p %>
For calender page. And;
/blog/tags/<%= tagname %>
/blog/tags/<%= tagname %>/page/<%= p %>
For tag pages.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Screenshot: