【问题标题】:Including markdown inside yaml front-matter在 yaml front-matter 中包含 markdown
【发布时间】:2014-03-14 15:55:48
【问题描述】:

我的一个网页需要包含多行项目(图片、标题、描述)。描述必须接受降价。在 Jekyll 中没有插件或创建多个文件(每个项目一个文件)的情况下,我还没有找到任何方法来做到这一点。

另一个要求是该站点由Github Pages 构建。即:没有 Jekyll 插件,Redcarpet 降价。

理想情况下,我希望创建一个 Jekyll 数据文件 (_data/products.yml),其中包含类似于下面的结构。请注意,Description 包含降价列表和格式。

- Name: Company A
  Year: 2005
  Description: >
    I was responsible for the following:
    - Review of contracts
    - Hiring
    - Accounting

- Name: Company B
  Year: 2010
  Description: >
    My role included **supervising** the marketing team and leading **publicity**.

我看到的另一个选择是将 Front-matter 与上述信息一起使用。它稍微麻烦一些,因为它将数据与特定页面联系起来(例如:work-experience.md)。

我在上面尝试了各种变体,但格式从未转换为 HTML。怎么处理?

【问题讨论】:

    标签: yaml jekyll github-pages


    【解决方案1】:

    如果您不想使用插件,我相信最好的办法是将它放在 _data 中,尽管不确定它是否是有效的 YAML,甚至是有效的 YAML 是否是 _data 内容的要求。

    你有没有试过使用markdownify这样的函数

    {{ site.data.products.description | markdownify }}

    http://jekyllrb.com/docs/templates/

    【讨论】:

    • 是的,markdownify 过滤器完美运行。将 markdown 作为某些 YAML 字段的值没有问题。我已经能够推送到 Github Pages 并且一切都很好。谢谢。
    • 很棒的建议,直到现在才看到“markdownify”,就像一个魅力。
    • 嗨!你能告诉我如何在 assemble.io 中使用它吗?
    猜你喜欢
    • 2014-10-23
    • 1970-01-01
    • 2015-12-24
    • 2011-10-26
    • 2014-06-04
    • 2015-11-23
    • 2014-04-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多