Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
24 lines (22 sloc) 920 Bytes
- var articles = []
for article, slug in public.articles._data
if article.date && article.published!==false
- article.slug = slug
- articles.push(public.articles._data[slug])
//- Iterate over the articles array
each article, i in articles.sort(function(a,b){ a = new Date(a.date); b = new Date(b.date); return b<a?-1:b>a?1:0; }).slice(0, postlimit)
//- Article slug is the old object key that matched the file name,
//- Like "a-post" for example
//- Match it against the current page
if article.slug == current.source
//- Previous is one before this array item
//- Next is one after
//- Variables make it easy to template
- prev = articles[i - 1]
- next = articles[i + 1]
//- The actual links
ol.post-nav
if prev
a.post-prev(href="#{ prev.slug }") #{ prev.title }
if next
a.post-next(href="#{ next.slug }") #{ next.title }