how can I retrieve the latest 5 blog posts on the homepage of my docpad website? -


i have been testing docpad cms , want know how can display in homepage latest 5 posts blog.

i have looked examples no luck far.

do need plugin functionality? @ moment im using following modules:

"docpad-plugin-marked": "~2.1.1", "docpad-plugin-stylus": "~2.3.0", "docpad-plugin-coffeekup": "~2.1.5", "docpad-plugin-cleanurls": "~2.4.3", "docpad-plugin-coffeescript": "~2.2.1", "docpad": "~6.32.0", "docpad-plugin-minicms": "~2.1.1" 

in docpad.coffee file under collections have

posts: ->       @getcollection('documents').findalllive({relativeoutdirpath:path.join('blog','post')},[date:-1]) 

i suppose key here ordering of collection date attribute ("date:-1")

then in "eco" file can access collection using: @getcollection('posts'). will, of course, give posts - if want last n posts take first n documents in collection.

 <% document in  @getcollection('posts').tojson().slice(0,5): %> <li>   <a href="<%=document.url%>" title="<%=document.title%>"><%=document.title%>   </a> </li> <% end %> 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -