I am creating a portfolio and just want to print the next and previous project link on each project details page using DocPad (which uses the Backbone collections). The code here is from my projects.html.eco template. The @document object is the document being viewed.
<% for document in @getCollection('projects').toJSON() : %> <% if document.url.indexOf('/posts') is @document.url.indexOf('/projects') + 1: %> <a href="<%= document.url %>" class="next"><img src="/images/rt_arrow.png" alt="" /></a> <% end %> <% if document.url.indexOf('/posts') is @document.url.indexOf('/projects') - 1: %> <a href="<%= document.url %>" class="previous"><img src="/images/lft_arrow.png" alt="" /></a> <% end %> <% end %>
Let me know if I can provide more information!
Thanks!
source share