pattex / jekyll-tagging

Jekyll plugin to automatically generate a tag cloud and tag pages.
385 stars 76 forks source link

page.posts is not site.posts #13

Closed igorw closed 9 years ago

igorw commented 11 years ago

Index templates use site.posts, but this plugin stores the posts in page.posts. This is really annoying because in order to re-use templates, I need to do:

{% if page.posts %}
    {% assign posts = page.posts %}
{% else %}
    {% assign posts = site.posts %}
{% endif %}

{% for post in posts %}
    ...
{% endfor %}

Unless there is a better way to do it -- but I didn't find one.

Ideally they would both just store it in site.posts.

pattex commented 11 years ago

I don't know if I understand exactly what you mean but maybe there's a little misunderstanding.

site.posts (which is provided by jekyll) is an array of all the posts of your jekyll site/blog. page.posts (on a tag page only!) is an array of all the posts tagged with the specific tag of this page. I don't think that it would be super smart to overwrite the one with the other.

igorw commented 11 years ago

My particular use case for tags is to generate tag-specific listings and feeds. I also have global listings and feeds. I want to re-use the same template for those two cases.

Am I supposed to do it the way I am right now, with assign? It seems like quite the hack to me.

pattex commented 11 years ago

Am I supposed to do it the way I am right now, with assign? It seems like quite the hack to me.

I would think so. Evaluating a condition to decide behaviour on different circumstances seems legit to me.

alexunder commented 9 years ago

{% if post.category not contains 'blog'%} some actions {% endif %}

There is any mistake in the code snippet above? The github send me a page build error. I can't fix it. Thanks!

pattex commented 9 years ago

@alexunder I think this is a Jekyll may be Liquid related question and not at all topic of this issue. And to be honest, I don't know. I just didn't work a lot with Jekyll the last two years.