In Hexo.js, when you want to output some articles, you loop using .sort
, .limit
and .each
, for example:
<% site.posts.sort('date', 'desc').limit(8).each(function(post){ %>
<div id="post-1" class="post">
<%= post.title %>
all the other post tags and content
</div>
<% }) %>
How do you set the id number post-X
to be dynamically incremented, for example first post would get id="post-1"
, second id="post-2"
and so on?