我想将
md
文件放入集合 _notes
中,但将它们分组到文件夹中。一个大的 html
主题将从多个 md
文件生成。
这是我的尝试
_notes
├-database.md
└-compiler.md
_note_sections
├-database
| ├-indexing.md
| └-concurrency.md
└-compiler
├-assembly.md
└-parsing.md
-layouts
├-note.html
└-note_section.html
md
中的每个_notes_sections
文件都存储实际内容并具有布局note_section
,例如
---
section_title: xxx
layout: note_section
---
Testing text
{% highlight python %}
dfs_r(Node n, MBR w)...
{% endhighlight %}
md
中的每个_notes
文件通过从可扩展箭头显示它们来组合多个note_sections,并具有布局note
,这是布局文件note.html
:
---
layout: default
---
{% include mathjax.html %}
{% assign subfolder = 'compiler/' %}
<ul class="note_sections">
{% for note_section in site.note_sections %} {% if note_section.relative_path contains subfolder %}
<li>
<details>
<summary>{{note_section.section_title}}</summary>
{{note_section.content}}
</details>
</li>
{% endif %} {% endfor %}
</ul>
而
note_section.html
只是
---
layout: default
---
{{content}}
但是,当将
html
生成为 _site/notes
时,compiler.html
仅具有原始 Markdown 内容
.
.
.
<li>
<details>
Testing text
{% highlight python %}
dfs_r(Node n, MBR w)...
{% endhighlight %}
</details>
</li>
.
.
.
而不是将 note_section markdowns 变成
html
,这会将 markdown 中的代码片段变成这些长的 html
标签
<figure class="highlight"><pre><code class="language-python" data-lang="python"><span class="nf">
但是,我确实得到了一个
_site/note_sections/compiler/assembly.html
文件,其中包含从 note_section markdown 生成的正确 html
。这是我想放在 notes
下的大主题 html 中的内容,而不仅仅是将原始 markdown 放在里面。
这花了我一段时间才弄清楚发生了什么......我认为集合并不意味着直接呈现为页面......这意味着它们需要从另一个实际页面引用。
所以我认为这是一个简单的修复...您要么需要一个引用 _notes 的新页面,要么您可以将 _notes 文件本身转换为页面。
文档没有明确说明这个...限制?...但这是我对这些“应该”如何工作的感觉:https://jekyllrb.com/docs/collections/