1

On my index page I wanna give out two seperate lists of articles (I wouldn't mind using the pagination plugin by the way), and I want to list the last 5 in each "category". But I have no idea how I can count up in the loop.

I already tried

#{news-loop} = #{news-loop} + 1

but that did not work.

- var news-loop = 0
block content
  section.work.index
    h2 Arbeiten
    a.archive(href='/arbeiten') Übersicht
    ul
      each article in articles
        if article.metadata.work
          li
            h3
              a(href=article.url)= article.title
koffeingeladen
  • 325
  • 1
  • 2
  • 11

2 Answers2

1

Normal Jade iteration should accomplish this. The issue with your code is you cannot have hyphens in variable names.

maged
  • 859
  • 10
  • 24
1

You could limit the amount of elements passed to the each loop:

each article in articles.slice(0, 5)

however it seems to me this kind of data processing should better happen before the view is generated.

hvdd
  • 514
  • 4
  • 7