Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Trying to display first post from query object

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #203326
    matthisco
    Participant

    Hello,

    I have this piece of code in my jade template which works fine like this:

    each post in locals.data.posts
    ul
    each avit in post
    li
    a(href='/blog/post/' + avit.slug) #{avit.title}

    However, I would like to display the first post only on the same page and I am trying to do it by using this syntax:

    a(href='/blog/post/' + locals.data.posts[0].avit[0].slug) #{locals.data.posts[0].avit[0].title}

    Which shows empty values, can anyone please tell me how I show the first post?

    Many thanks

    #203333
    nkrisc
    Participant

    Are you using some sort of framework?

    #203346
    matthisco
    Participant

    Thanks for the reply, it’s a standard keystoneJs install using thé built in blog page

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.