使用 Pug 迭代 Jekyll 帖子

Iterate Jekyll Posts using Pug

我刚开始使用哈巴狗,我想完成的基本上是将其转换为哈巴狗代码。

<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>

这是我的代码,但在编译时总是出错。

#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 }})

我也有同样的亲,像这样插入纯文本就解决了

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