【问题标题】:Jekyll liquid show more postsJekyll 液体 显示更多帖子
【发布时间】:2018-11-19 13:50:05
【问题描述】:

我有一个页面显示我的帖子,如下所示

{% for post in site.posts limit:3 %}
<a href="{{site.baseurl}}{{post.url}}" style="text-decoration: none; margin: 1rem;">
    <div class="newsBox">
        <div style="margin: auto;">
            <h1 style="text-align: center; color: white;">{{post.title}}</h1>
            <p style="text-align: center; color: white;">
                {{post.description}}
            </p>
            <p style="text-align: center; color: #101a31; font-style: italic; font-size: 1.2rem;">
                {{post.date | date:"%d-%m-%Y"}}
            </p>
        </div>
    </div>
</a>
{% endfor %}

这很好用,但如果有更多未显示的帖子,我也想显示一个“更多”按钮。有谁知道如何做到这一点?

【问题讨论】:

  • 好的,所以我通过这样做{% assign psize = site.posts | size %} {% if psize &gt; 3 %} &lt;p&gt;more posts&lt;/p&gt; {% endif %} 搞定了,但现在我需要知道如何显示接下来的 3 个帖子..

标签: html jekyll liquid


【解决方案1】:

您希望将用户重定向到具有更多帖子的另一个页面,还是将帖子显示在同一页面上?

Jekyll 为您构建网站,然后将其设为静态,因此您无法在构建后让 Jekyll 向您的页面添加更多内容的按钮。

如果您想在页面上显示更多内容,您可以通过遍历帖子文件夹、将其注释掉并在单击按钮时删除评论来解决此问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-19
    • 1970-01-01
    • 2018-07-09
    • 2020-08-27
    • 1970-01-01
    • 1970-01-01
    • 2014-12-13
    相关资源
    最近更新 更多