我正在制作一个投资组合,并希望使用 DocPad(使用 Backbone 集合)在每个项目详细信息页面上简单地打印下一个和上一个项目链接。这里的代码来自我的模板projects.html.eco。@document 对象是当前正在查看的文档。
<% 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 %>
让我知道我是否可以提供更多信息!
谢谢!