【问题标题】:How to use assemble to add a directory of markdown files to my index如何使用 assemble 将 markdown 文件的目录添加到我的索引
【发布时间】:2014-08-28 08:51:57
【问题描述】:

我正在尝试将静态站点生成添加到站点中,以使其更有条理并且更容易做出贡献。索引文件有一个带有无序列表的部分和许多共享相同格式的列表项。我想从 Markdown 文件的文件夹中动态加载这些列表项。

我正在尝试做类似的事情

{{forEach file in the folder}}
<li>
  <div class="container">
    <div class="display">
      {{markdown content of the file}}
    </div>
    <div class="code">
      <pre>
        <code class="language-javascript">
          {{ string from YFM in markdown file }}
        </code>
      </pre>
    </div>
  </div>
</li>
{{/forEach}}

我实际上并不希望将每个 markdown 文件组装到我的 dist 文件夹中它自己的页面中,只是用作我的索引文件的部分动态集合。

这可能吗?

【问题讨论】:

    标签: gruntjs yaml markdown assemble


    【解决方案1】:

    显然从未完成的教程的这两个部分解释了如何使用 markdown 文件作为部分的动态集合以集成到索引站点上:

    在迭代 md 文件的循环中,我使用此构造将 yfm 剥离的内容“包含”为索引站点上的内容(我花了很长时间才弄清楚):

    {{#markdown}}
      {{page}}
    {{/markdown}}
    

    另请参阅http://assemble.io 上有关集合的文档,但请注意,关于集合的选项哈希(name: posts 与 name: post,即单数与复数和自动变形)存在一些相互矛盾的信息与inflection: post 相比,但底线是:坚持上面链接中的变体:))

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-22
      • 2016-04-23
      • 1970-01-01
      相关资源
      最近更新 更多