以11ty遍历子目录中的项目

时间:2020-09-21 20:10:37

标签: liquid eleventy

使用以下目录结构,我需要遍历子目录中的项目:

|_ _includes
|_ _site
|_ books
   |_ book-one
      |_ index.html
      |_ sections
         |_ section-one
            |_ index.html
            |_ chapters
               |_ index.html
               |_ chapter-one.html
               |_ chapter-two.html
               |_ chapter-three.html
               |_ chapter-four.html

在上面的section-one/index.html中应循环浏览并列出chapters子目录中的项目。

每个chapter-x.html都包含YAML前端问题,例如:

---
title: This is the Title
layout: layouts/chapter.yaml
---
<p>Lorem ipsum dipity doo</p>

以及我的版面布局

---
layout: layouts/master.liquid
---
<ol>
{%- for chapter in chapters -%}
  <li>{{ title }}</li>
{%- endfor -%}
</ol>

0 个答案:

没有答案