集合中的Jekyll链接文档?

集合中的Jekyll链接文档?,jekyll,Jekyll,在杰基尔面前,有没有办法引用其他文件 我有一个自定义集合,希望在每个文档中添加元数据,例如“父主题”(指向父主题的链接)和“子主题”(文档数组)或“相关主题” 有了这样的引用,我可以访问链接文档的元数据,比如它们的标题、url或其他任意数据 其思想是文档的层次结构,包含主题、子主题、子主题等。主题页面可以显示子主题列表,或父主题的面包屑等。真正的问题应该得到真正的答案。我还遇到了这个文档问题。接下来,我开始使用集合。这个想法是为了 反映主题/子主题安排的内容表 每页上都有面包屑 我放弃了,因

在杰基尔面前,有没有办法引用其他文件

我有一个自定义集合,希望在每个文档中添加元数据,例如“父主题”(指向父主题的链接)和“子主题”(文档数组)或“相关主题”

有了这样的引用,我可以访问链接文档的元数据,比如它们的标题、url或其他任意数据


其思想是文档的层次结构,包含主题、子主题、子主题等。主题页面可以显示子主题列表,或父主题的面包屑等。

真正的问题应该得到真正的答案。我还遇到了这个文档问题。接下来,我开始使用
集合
。这个想法是为了

  • 反映主题/子主题安排的内容表
  • 每页上都有面包屑
我放弃了,因为对
页面进行编码是最简单的。下面是我如何使用页面编写文档的

先决条件:
  • 文档在文件夹中,例如:文档

  • permalink
    在_config.yml中设置为
    pretty

  • 文件夹层次结构描述文档组织

示例

documentation
|--index.html
|--chapter-1
|  |--index.html
|
|--chapter-2
|  |--index.html
|  |
|  |--part-1
|  |  |--index.html
|  |  |--subpart-1
|  |     |--index.html
|  |--part-2
|  |  |--index.html
|  |
|  |--part-3.html
defaults:
  -
    scope:
      path: "documentation"
      type: pages

    values:
      isDoc: true # allows quick extraction from site.pages
      layout: page
注意:
documentation/chapter-2/part-2/index.html
也可以是
documentation/chapter-2/part-2.html
,因为
permalink
设置为
pretty
,生成的页面将位于
documentation/chapter-2/part-2/index.html

  • 同一级别的页面根据
    权重
    前置变量进行排序。这可以是你想要的任何东西。 按第十位编号,便于插入新文档
正面事件示例

---
title: My title
weight: 10
---
  • 文档从
    \u config.yml
示例

documentation
|--index.html
|--chapter-1
|  |--index.html
|
|--chapter-2
|  |--index.html
|  |
|  |--part-1
|  |  |--index.html
|  |  |--subpart-1
|  |     |--index.html
|  |--part-2
|  |  |--index.html
|  |
|  |--part-3.html
defaults:
  -
    scope:
      path: "documentation"
      type: pages

    values:
      isDoc: true # allows quick extraction from site.pages
      layout: page
一旦具备了这些先决条件,就可以很容易地打印内容表和面包屑了

目录 \u包含/显示children.html

{% assign parentDir = include.dir %}
{% if parentDir == nil %}<h1>You must specify a root directory</h1>{% endif %}

{% assign allDocs = include.docs %}
{% if allDocs == nil %}{% assign allDocs = site.pages | sort: "weight" %}{% endif %}

{% assign level = include.level %}
{% if level == nil %}{% assign level = parentDir | remove_first: "/" | split:"/" | size %}{% endif %}

{% assign maxLevel = include.maxLevel %}
{% if maxLevel == nil %}{% assign maxLevel = 100 %}{% endif %}

{% assign nextLevel = level | plus : 1 %}

{% comment %}+++++++++++++++++++++++++++++++++++++++++++++++++
Looking for all page in this path with the same level (siblings)
This avoid to deep recursion and error like :
__ Liquid Exception: Nesting too deep __
+++++++++++++++++++++++++++++++++++++++++++++++++{% endcomment %}

{% assign siblings = "" | split: "/" %}
{% for s in allDocs %}
    {% assign sPageLevel = s.url | remove_first: "/" | split:"/" | size %}
    {% if sPageLevel == level and s.url contains parentDir %}
        {% if s.title %}{% assign siblings = siblings | push: s %}{% endif %}
    {% endif %}
{% endfor %}

<ul>
{% for p in siblings %}
    <li><a href="{{site.baseurl}}{{p.url}}"{%if p.url == page.url%} class="active"{%endif%}>{{ p.title }}</a>
    {% if nextLevel <= maxLevel %}
      {% include show-children.html dir=p.dir docs=allDocs level=nextLevel maxLevel=maxLevel %}
    {% endif %}
    </li>
{% endfor %}
</ul>

{% comment %}+++++++++++++++++++++++++++++++++++++++++++++++++
Because all variables are globales (all includes have the same scope)
we restore level and nextLevel variables to parent values
+++++++++++++++++++++++++++++++++++++++++++++++++{% endcomment %}
{% assign level = level | minus : 1 %}
{% assign nextLevel = nextLevel | minus : 1 %}
{% assign minLevel = include.minLevel %}
{% if minLevel == nil %}{% assign minLevel = 1 %}{% endif %}

<div class="breadcrumb">
<p>You are here : </p>
{% assign documents = site.pages | where: "isDoc", true | sort: "weight" %}
{% include get-parents.html page=page minLevel=minLevel docs=documents %}
<p>{{ page.title }}</p>
</div>

<style type="text/css">
.breadcrumb p { display: inline; }
.breadcrumb p+p+p:before { content:"» "; }
</style>
{% assign currentPage = include.page %}
{% assign minLevel    = include.minLevel %}
{% assign allDocs     = include.docs %}
{% assign pageLevel   = currentPage.dir | remove_first: "/" | split:"/" | size %}
{% assign parentLevel = pageLevel | minus: 1 %}
{% if parentLevel >= minLevel %}
    {% for p in allDocs %}
        {% assign pPageLevel = p.dir | remove_first: "/" | split:"/" | size %}
        {% if pPageLevel == parentLevel and currentPage.dir contains p.dir %}
            {% include get-parents.html page=p minLevel=minLevel docs=allDocs %}
            <p><a href="{{site.baseurl}}{{p.url}}">{{ p.title }}</a></p>
        {% endif %}
    {% endfor %}
{% endif %}
在页面布局上,如果只想打印页面子项,可以执行以下操作:

{% assign documents = site.pages | where: "isDoc", true | sort: "weight" %}
{% assign level = page.dir | remove_first: "/" | split:"/" | size %}
{% assign childrenLevel = level | plus : 1 %}
{% include show-children.html docs=documents dir=page.dir level=childrenLevel %}
面包屑 \u包括/breadcrumb.html

{% assign parentDir = include.dir %}
{% if parentDir == nil %}<h1>You must specify a root directory</h1>{% endif %}

{% assign allDocs = include.docs %}
{% if allDocs == nil %}{% assign allDocs = site.pages | sort: "weight" %}{% endif %}

{% assign level = include.level %}
{% if level == nil %}{% assign level = parentDir | remove_first: "/" | split:"/" | size %}{% endif %}

{% assign maxLevel = include.maxLevel %}
{% if maxLevel == nil %}{% assign maxLevel = 100 %}{% endif %}

{% assign nextLevel = level | plus : 1 %}

{% comment %}+++++++++++++++++++++++++++++++++++++++++++++++++
Looking for all page in this path with the same level (siblings)
This avoid to deep recursion and error like :
__ Liquid Exception: Nesting too deep __
+++++++++++++++++++++++++++++++++++++++++++++++++{% endcomment %}

{% assign siblings = "" | split: "/" %}
{% for s in allDocs %}
    {% assign sPageLevel = s.url | remove_first: "/" | split:"/" | size %}
    {% if sPageLevel == level and s.url contains parentDir %}
        {% if s.title %}{% assign siblings = siblings | push: s %}{% endif %}
    {% endif %}
{% endfor %}

<ul>
{% for p in siblings %}
    <li><a href="{{site.baseurl}}{{p.url}}"{%if p.url == page.url%} class="active"{%endif%}>{{ p.title }}</a>
    {% if nextLevel <= maxLevel %}
      {% include show-children.html dir=p.dir docs=allDocs level=nextLevel maxLevel=maxLevel %}
    {% endif %}
    </li>
{% endfor %}
</ul>

{% comment %}+++++++++++++++++++++++++++++++++++++++++++++++++
Because all variables are globales (all includes have the same scope)
we restore level and nextLevel variables to parent values
+++++++++++++++++++++++++++++++++++++++++++++++++{% endcomment %}
{% assign level = level | minus : 1 %}
{% assign nextLevel = nextLevel | minus : 1 %}
{% assign minLevel = include.minLevel %}
{% if minLevel == nil %}{% assign minLevel = 1 %}{% endif %}

<div class="breadcrumb">
<p>You are here : </p>
{% assign documents = site.pages | where: "isDoc", true | sort: "weight" %}
{% include get-parents.html page=page minLevel=minLevel docs=documents %}
<p>{{ page.title }}</p>
</div>

<style type="text/css">
.breadcrumb p { display: inline; }
.breadcrumb p+p+p:before { content:"» "; }
</style>
{% assign currentPage = include.page %}
{% assign minLevel    = include.minLevel %}
{% assign allDocs     = include.docs %}
{% assign pageLevel   = currentPage.dir | remove_first: "/" | split:"/" | size %}
{% assign parentLevel = pageLevel | minus: 1 %}
{% if parentLevel >= minLevel %}
    {% for p in allDocs %}
        {% assign pPageLevel = p.dir | remove_first: "/" | split:"/" | size %}
        {% if pPageLevel == parentLevel and currentPage.dir contains p.dir %}
            {% include get-parents.html page=p minLevel=minLevel docs=allDocs %}
            <p><a href="{{site.baseurl}}{{p.url}}">{{ p.title }}</a></p>
        {% endif %}
    {% endfor %}
{% endif %}
打印
第1章>第1部分

{% include breadcrumb.html %}
{% include breadcrumb.html minLevel=2 %}
它能更简单吗


.

谢谢您的完整回答!我需要一段时间来消化。。。不幸的是,它首先从集合移动到页面…它可以将
\u documentation
重命名为
documentation
,而您的集合现在是一个页面文件夹。添加一些
weight
来订购您的物品,您就完成了。它会像在集合中一样将.md文件转换为.html吗?确实会。刚查过。我想知道集合给了我哪些页面现在没有的东西…是的,它会像任何md页面或帖子一样将.md转换为.html。