2

我有一个使用 Jekyll 支持的食谱网站,现在我想将微数据(itemscope、、itemprop等)添加到输出静态页面中。我有几个列表(成分、方向等),我不确定如何让 Jekyll 渲染这些并添加微数据。

我假设我需要一个转换器或过滤器或其他一些东西,但我几乎没有使用 Jekyll 的经验。以前有人做过类似的事情吗?

4

1 回答 1

1

在kramdown 文档中找到了一种方法

  • {: itemprop="ingredient"} 2 汤匙黄油
  • {: itemprop="ingredient"} 1 杯洋葱丁
  • {: itemprop="ingredient"} 1 杯胡萝卜丝

但是如果:

  • 你把你的原料放在最前面

我的食谱.md

---
layout: page
title: My nice recipe
ingredients:
    - 2 tablespoons butter
    - 1 cup diced onion
    - 1 cup shredded carrot
---

{% include recipe_head.html %}

###How to do it

...
  • 做一个模板

**_includes/recipe_head.html

<h3>{{ page.title }}</h3>
<h4>Ingredients</h4>
<ul>
    {% for ingredient in page.ingredients %}
    <li itemprop="ingredient">{{ ingredient }}</li>
    {% endfor %}
</ul>

这将更易于维护。

于 2015-01-23T08:55:54.323 回答