【问题标题】:Order posts by post yml front-matter number按帖子 yml 前端编号排序帖子
【发布时间】:2014-04-10 00:33:34
【问题描述】:

我将每个帖子都作为公司在建筑物中,我想通过suite 为每个帖子(公司)订购每个帖子的 yml 前端中设置的数字。我该怎么做?

【问题讨论】:

    标签: jekyll


    【解决方案1】:

    Here's another question that asked something similar,只是使用“常规”页面而不是博客文章。

    根据您的需求调整接受的答案suite 和帖子,而不是 weight 和页面),您需要执行以下操作:

    在每个帖子的前面定义suite

    ---
    layout: post
    title: whatever
    date: 2014/04/19 00:00
    suite: 3
    ---
    

    显示按suite排序的所有帖子列表:

    <ul>
    {% for suite in (1..10) %}
        {% for post in site.posts %}
            {% if post.suite == suite %}
                <li><a href="{{ post.url }}">{{ post.title }}</a></li>
            {% endif %}
        {% endfor %}
    {% endfor %}
    </ul>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-13
      • 1970-01-01
      • 1970-01-01
      • 2018-05-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多