1

我有一些液体标记在我_includes/的机器上渲染得很好,但是当我只推送到gh-pages包含的 div 渲染时。它应该为我的网站生成导航,按页面类别分组。我已经在我的机器上匹配了 ruby​​gems 来模仿我在这里看到的内容。我的流动语法有什么问题会阻止它在 GitHub Pages 中呈现吗?

<!-- NAVBAR -->
<div class="navbar">
{% assign categories = site.pages | map: 'to_liquid' | map: 'category' %}
{% assign usedCategories = '' %}
{% for category in categories %}{% if category %}
    {% capture categoryToCheck %},{{ category }},{% endcapture %}
    {% unless usedCategories contains categoryToCheck %}
    <h3 style="color: red; text-transform: capitalize;">{{ category | replace: '-', ' ' }}</h3>
        {% for doc in site.pages %}{% if doc.category == category %}
        <a href="{{ site.baseurl }}{{ doc.url }}">{{ doc.title }}</a>
        {% endif %}{% endfor %}
        {% capture usedCategories %}{{ usedCategories }}{{ categoryToCheck }}{% endcapture %}
    {% endunless %}
{% endif %}{% endfor %}
</div>

注意:我认为我已经将问题归结map: 'category'site.pages | map: 'to_liquid'生成相同的输出(但顺序不同)。map: 'category'在我的机器上从液体中提取字段,但这gh-pages不会发生。如果您有任何建议,请告诉我!

4

1 回答 1

1

我通过不使用 map 属性来解决这个问题。这是一个片段:

{% assign usedCategories = '' %}
{% for page in site.pages %}
  {% unless usedCats contains page.category %}
    <h3 style="color: red; text-transform: capitalize;">{{ page.category | replace: '-', ' ' }}</h3>
  {% capture usedCategories %}{{ usedCategories }}{{page.category}}{% endcapture %}
  {% endunless %}
{% endfor %}
于 2013-03-10T03:03:18.040 回答