2016-04-26 6 views
0

Ich habe eine Seite mit allen Posts geordnet nach Tag. Die Sache ist, dass ich nur einige Tags anzeigen möchte, nicht alle. Die Sache würde nach dem "for tag in site.tags" ein if like-Tag == x implementieren. Ich bin neu in Jekyll und Rubin und ich weiß nicht, wie es zu tun:/Implementieren Sie eine if in jekyll-Tag-Seite

{% capture site_tags %}{% for tag in site.tags %}{{tag | first }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %} 


{% assign tag_words = site_tags | split:',' | sort %} 


<ul class="tags"> 
{% for item in (0..site.tags.size) %}{% unless forloop.last %} 
{% capture this_word %}{{ tag_words[item] }}{% endcapture %} 
<li> 
<a href="#{{ this_word | cgi_escape }}" class="tag">{{ this_word }} 
<span>({{ site.tags[this_word].size }})</span> 
</a> 
</li> 
{% endunless %}{% endfor %} 
</ul> 

<div> 
{% for item in (0..site.tags.size) %}{% unless forloop.last %} 
{% capture this_word %}{{ tag_words[item] }}{% endcapture %} 
<h2 id="{{ this_word | cgi_escape }}">{{ this_word }}</h2> 
{% for post in site.tags[this_word] %}{% if post.title != null %} 
<div> 
<span style="float: left;"> 
<a href="{{ post.url }}">{{ post.title }}</a> 
</span> 
<span style="float: right;"> 
{{ post.date | date_to_string }} 
</span> 
</div> 
<div style="clear: both;"></div> 
{% endif %}{% endfor %} 
{% endunless %}{% endfor %} 
</div> 

Antwort

0

ändert diese:

{% capture site_tags %} 
    {% for tag in site.tags %}...{% endfor %} 
{% endcapture %} 

In diesem:

{% capture site_tags %} 
    {% for tag in site.tags %} 
    {% if tag.title != 'excludedtag' %}...{% endif %} 
    {% endfor %} 
{% endcapture %} 

und ändern ' outdtag 'zu dem Tag-Titel, den Sie ausschließen möchten.

Verwandte Themen