在 Jekyll 中比较日期

Comparing dates in Jekyll

我正在尝试将当前日期与 jekyll/liquid 中 post 的日期进行比较。如果当前日期小于post的日期,那么我要显示post的标题。

到目前为止,这是我的代码:

 <header class="announce-ticker">
  <div class="container">
    {% capture currentDate %}
      {{ 'now' | date: '%s'}}
    {% endcapture %}
    {% assign eventCount = 0 %}
    {% assign eventPosts = site.posts %}
    {% for post in eventPosts %}
      {% capture postDate %}
        {{ post.date | date: '%s'}}
      {% endcapture %}
      {% if currentDate < postDate %}
        {% post.title %}
        {% assign eventCount = 1 %}
      {% endif %}
      {{ currentDate}}
      {{ postDate }}
    {% endfor %}

    {% if eventCount == 0 %}
      <p>No events</p>
    {% endif %}

  </div>
</header>

我的问题是当 post 大于当前日期时它没有显示。

如有任何帮助,我们将不胜感激。谢谢!

默认情况下不发布未来日期的帖子。通过命令行启用它们的基本方法是使用 future 选项:

jekyll serve --future

或者,您可以将 future 参数添加到您的 _config.yml:

future: true

this article 中的更多选项。