使用Jekyll列出所有博客文章(包含内容)

Mat*_*rts 7 jekyll

我正在尝试展示杰基尔的前三篇博文.使用Jekyll引导程序,我看到有一个帖子(布局和底层主题页面)的布局 - 我想要做的是为每个帖子重复帖子布局..类似于:

  {% for post in site.posts %}
    -- Render the post layout for this post.
  {% endfor %}
Run Code Online (Sandbox Code Playgroud)

我不知道如何在不必复制帖子布局的内容的情况下如何做到这一点,并将其添加到for循环中,或者创建一个JB include,它仍然无法解决问题'我仍然会有复制并粘贴post html标记.

Mat*_*rts 7

最后,我意识到我不需要大部分来自帖子布局的标记,所以我采取了我需要的东西并将其嵌入到for循环中.

{% for post in site.posts %}
{% include JB/post_content %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

和post_content

<article class="unit-article layout-post">
    <div class="unit-inner unit-article-inner">
        <div class="content">
            <div class="bd">
                <div class="entry-content">
                    {{ post.content }}
                </div><!-- entry-content -->
            </div><!-- bd -->
        </div><!-- content -->
    </div><!-- unit-inner -->
</article>
Run Code Online (Sandbox Code Playgroud)