juscuizon
juscuizon

Reputation: 51

Iterate Jekyll Posts using Pug

I'm new to using pug, what I want to accomplish basically is convert this to pug code.

<div id="home">
   <h1>Blog Posts</h1>
   <ul class="posts">
      {% for post in site.posts %}
          <li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ post.url  }}">{{ post.title }}</a></li>
      {% endfor %}
   </ul>
</div>

This is my code but keeps getting errors when compiling.

#home 
    h1 Blog Posts
    - var _posts = [_site.posts]

    ul.blog
        each post in _posts
            li 
            span
                 a(href={post.date | date_to_string}) 
            &raquo a(href={{ post.url }}>{{ post.title }})

Upvotes: 0

Views: 250

Answers (1)

Z.better
Z.better

Reputation: 398

I have the same pro, and I solve it by inseting plain text like these

.posts-wrap
  ul
    |{% for post in site.posts %}
    |  <li>
    |    hi,there
    |  </li>
    |{% endfor %}

Upvotes: 0

Related Questions