2013-03-08 171 views
1

我在我的_includes/中有一些液体标记,在我的机器上呈现良好,但是当我推到gh-pages时,只有包含div呈现。它应该为我的网站生成导航,并按页面分类进行分组。我已经匹配了我机器上的rubygems,模仿我看到的here。有没有什么我做错了我的液体语法阻止它在GitHub页面中呈现?GitHub页面不会渲染Jekyll包括

<!-- 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这没有发生。请让我知道,如果你有任何建议!

+0

哈哈哈哈!随意建议一个更简洁的解决方案,使类别阵列在液体中不同:p – 2013-03-08 13:39:56

回答

1

我得到这个想法没有使用地图属性。这里有一个片段:

{% 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 %} 
+0

关于[this]的任何想法(http://stackoverflow.com/q/34532476/2404470) – xameeramir 2015-12-30 15:53:31