如何使用yaml手动排序Jekyll页面?

如何使用yaml手动排序Jekyll页面?,jekyll,Jekyll,我正在将一个旧站点从PHP CMS转换为Jekyll,我希望保留手动排序的页面。起初,我认为我可以重命名文件以包含索引,例如01从这里开始.markdown,02了解更多信息.markdown等。如果我再往下添加一页,这会让事情变得很尴尬 理想情况下,我希望指定一个包含页面顺序的yaml文件。例如: category: basics pages: - start here - learn more - overview category: advanced pages: - d

我正在将一个旧站点从PHP CMS转换为Jekyll,我希望保留手动排序的页面。起初,我认为我可以重命名文件以包含索引,例如
01从这里开始.markdown
02了解更多信息.markdown
等。如果我再往下添加一页,这会让事情变得很尴尬

理想情况下,我希望指定一个包含页面顺序的
yaml
文件。例如:

category: basics
pages:
  - start here
  - learn more
  - overview

category: advanced
pages:
  - diving further
  - wrapping up
这可能吗?看看网站,他们似乎有一个手动订购的网站,但我不太明白如何


此外,为了使问题进一步复杂化,我希望将其分配到
页面
以便
页面。下一步
将在
基础
类别的最后一页之后自动移动到
高级
类别。

来自Jekyll documentation code

\u data/docs.yml

- title: chapter 1
  docs:
  - home
  - page
  - other

- title: Other chapter
  docs:
  - toto
  - etc
<div class="unit one-fifth hide-on-mobiles">
  <aside>
    {% for section in site.data.docs %}
    <h4>{{ section.title }}</h4>
    {% include docs_ul.html items=section.docs %}
    {% endfor %}
  </aside>
</div>
{% assign items = include.items %}
<ul>
{% for item in items %}
  {% assign item_url = item | prepend:"/docs/" | append:"/" %}
  {% if item_url == page.url %}
    {% assign c = "current" %}
  {% else %}
    {% assign c = "" %}
  {% endif %}
  {% for p in site.docs %}
    {% if p.url == item_url %}
      <li class="{{ c }}"><a href="{{ site.url }}{{ p.url }}">{{ p.title }}</a></li>
      {% break %}
    {% endif %}
  {% endfor %}
{% endfor %}
</ul>
{% comment %}
Map grabs the doc sections, giving us an array of arrays. Join, flattens all
the items to a comma delimited string. Split turns it into an array again.
{% endcomment %}
{% assign docs = site.data.docs | map: 'docs' | join: ',' | split: ',' %}

{% comment %}
Because this is built for every page, lets find where we are in the ordered
document list by comparing url strings. Then if there's something previous or
next, lets build a link to it.
{% endcomment %}

{% for document in docs %}
  {% assign document_url = document | prepend:"/docs/" | append:"/" %}
  {% if document_url == page.url %}
    <div class="section-nav">
      <div class="left align-right">
          {% if forloop.first %}
            <span class="prev disabled">Back</span>
          {% else %}
            {% assign previous = forloop.index0 | minus: 1 %}
            {% assign previous_page = docs[previous] | prepend:"/docs/" | append:"/" %}
            <a href="{{ previous_page }}" class="prev">Back</a>
          {% endif %}
      </div>
      <div class="right align-left">
          {% if forloop.last %}
            <span class="next disabled">Next</span>
          {% else %}
            {% assign next = forloop.index0 | plus: 1 %}
            {% assign next_page = docs[next] | prepend:"/docs/" | append:"/" %}
            <a href="{{ next_page }}" class="next">Next</a>
          {% endif %}
      </div>
    </div>
    <div class="clear"></div>
    {% break %}
  {% endif %}
{% endfor %}
在Jekyll中,文档包含在\u docs集合中,但这可以很容易地调整为与页面一起使用

中的导航包括/docs\u contents.html

- title: chapter 1
  docs:
  - home
  - page
  - other

- title: Other chapter
  docs:
  - toto
  - etc
<div class="unit one-fifth hide-on-mobiles">
  <aside>
    {% for section in site.data.docs %}
    <h4>{{ section.title }}</h4>
    {% include docs_ul.html items=section.docs %}
    {% endfor %}
  </aside>
</div>
{% assign items = include.items %}
<ul>
{% for item in items %}
  {% assign item_url = item | prepend:"/docs/" | append:"/" %}
  {% if item_url == page.url %}
    {% assign c = "current" %}
  {% else %}
    {% assign c = "" %}
  {% endif %}
  {% for p in site.docs %}
    {% if p.url == item_url %}
      <li class="{{ c }}"><a href="{{ site.url }}{{ p.url }}">{{ p.title }}</a></li>
      {% break %}
    {% endif %}
  {% endfor %}
{% endfor %}
</ul>
{% comment %}
Map grabs the doc sections, giving us an array of arrays. Join, flattens all
the items to a comma delimited string. Split turns it into an array again.
{% endcomment %}
{% assign docs = site.data.docs | map: 'docs' | join: ',' | split: ',' %}

{% comment %}
Because this is built for every page, lets find where we are in the ordered
document list by comparing url strings. Then if there's something previous or
next, lets build a link to it.
{% endcomment %}

{% for document in docs %}
  {% assign document_url = document | prepend:"/docs/" | append:"/" %}
  {% if document_url == page.url %}
    <div class="section-nav">
      <div class="left align-right">
          {% if forloop.first %}
            <span class="prev disabled">Back</span>
          {% else %}
            {% assign previous = forloop.index0 | minus: 1 %}
            {% assign previous_page = docs[previous] | prepend:"/docs/" | append:"/" %}
            <a href="{{ previous_page }}" class="prev">Back</a>
          {% endif %}
      </div>
      <div class="right align-left">
          {% if forloop.last %}
            <span class="next disabled">Next</span>
          {% else %}
            {% assign next = forloop.index0 | plus: 1 %}
            {% assign next_page = docs[next] | prepend:"/docs/" | append:"/" %}
            <a href="{{ next_page }}" class="next">Next</a>
          {% endif %}
      </div>
    </div>
    <div class="clear"></div>
    {% break %}
  {% endif %}
{% endfor %}


{%break%}
{%endif%}
{%endfor%}
{%endfor%}

页脚上一页/下一页导航位于\u includes/section\u nav.html

- title: chapter 1
  docs:
  - home
  - page
  - other

- title: Other chapter
  docs:
  - toto
  - etc
<div class="unit one-fifth hide-on-mobiles">
  <aside>
    {% for section in site.data.docs %}
    <h4>{{ section.title }}</h4>
    {% include docs_ul.html items=section.docs %}
    {% endfor %}
  </aside>
</div>
{% assign items = include.items %}
<ul>
{% for item in items %}
  {% assign item_url = item | prepend:"/docs/" | append:"/" %}
  {% if item_url == page.url %}
    {% assign c = "current" %}
  {% else %}
    {% assign c = "" %}
  {% endif %}
  {% for p in site.docs %}
    {% if p.url == item_url %}
      <li class="{{ c }}"><a href="{{ site.url }}{{ p.url }}">{{ p.title }}</a></li>
      {% break %}
    {% endif %}
  {% endfor %}
{% endfor %}
</ul>
{% comment %}
Map grabs the doc sections, giving us an array of arrays. Join, flattens all
the items to a comma delimited string. Split turns it into an array again.
{% endcomment %}
{% assign docs = site.data.docs | map: 'docs' | join: ',' | split: ',' %}

{% comment %}
Because this is built for every page, lets find where we are in the ordered
document list by comparing url strings. Then if there's something previous or
next, lets build a link to it.
{% endcomment %}

{% for document in docs %}
  {% assign document_url = document | prepend:"/docs/" | append:"/" %}
  {% if document_url == page.url %}
    <div class="section-nav">
      <div class="left align-right">
          {% if forloop.first %}
            <span class="prev disabled">Back</span>
          {% else %}
            {% assign previous = forloop.index0 | minus: 1 %}
            {% assign previous_page = docs[previous] | prepend:"/docs/" | append:"/" %}
            <a href="{{ previous_page }}" class="prev">Back</a>
          {% endif %}
      </div>
      <div class="right align-left">
          {% if forloop.last %}
            <span class="next disabled">Next</span>
          {% else %}
            {% assign next = forloop.index0 | plus: 1 %}
            {% assign next_page = docs[next] | prepend:"/docs/" | append:"/" %}
            <a href="{{ next_page }}" class="next">Next</a>
          {% endif %}
      </div>
    </div>
    <div class="clear"></div>
    {% break %}
  {% endif %}
{% endfor %}
{%comment%}
Map获取doc部分,为我们提供一个数组数组。加入,让一切变得平坦
将项目转换为逗号分隔的字符串。Split将其再次转换为数组。
{%endcomment%}
{%assign docs=site.data.docs | map:'docs'| join:','| split:','%}
{%comment%}
因为这是为每个页面构建的,所以让我们找到我们在订单中的位置
通过比较url字符串创建文档列表。那么如果有什么以前的或者
接下来,让我们构建一个指向它的链接。
{%endcomment%}
{%用于文档中的文档%}
{%assign document_url=document | prepend:“/docs/”| append:“/”%}
{%if document_url==page.url%}
{%if-forloop.first%}
返回
{%else%}
{%assign previous=forloop.index0 |减:1%}
{%assign previous_page=docs[previous]| prepend:“/docs/”| append:“/”%}
{%endif%}
{%if-forloop.last%}
下一个
{%else%}
{%assign next=forloop.index0 | plus:1%}
{%assign next_page=docs[next]|前置:“/docs/”|追加:“/”%}
{%endif%}
{%break%}
{%endif%}
{%endfor%}

这是一个非常出色、冗长的答案。非常感谢你。