danreeves / picotags

[Deprecated] Adds page tagging functionality to Pico.
MIT License
4 stars 3 forks source link

Article without Tags in meta ==> Posts tagged #: #10

Closed bricebou closed 10 years ago

bricebou commented 10 years ago

Dan,

If an article doesn't have Tags in its meta, or if the meta Tags is empty, the artile doesn't appear but instead I have a page with the article meta.title but its content is something like this:

Posts tagged #:

with a list of all the articles...

I've tried to modify my theme index.html but without result...

Here is the scheme I'm using, based on your documentation:

            {% if is_front_page %}
            <!-- front page -->
                {{ content }}
            <!-- front page -->

            {% elseif meta.tags %}
            <!-- blog post -->
                <article>
                    <h1>{{ meta.title }}</h1>
                    {{ content }}

                    <p class="meta">
                        Tags : 
                        {% for tag in meta.tags %}
                            <a href="{{ base_url }}/tag/{{ tag }}">#{{ tag }}</a>
                        {% endfor %}
                    </p>
                </article>
            <!-- blog post -->
            {% elseif pages and meta.title != 'Error 404' %}
            <!-- tags page -->
                <p>Posts tagged <a href="{{ page.url }}">#{{ current_tag }}</a>:</p>
                {% for page in pages %}

                        <article>
                            <h2><a href="{{ page.url }}">{{ page.title }}</a></h2>
                            <p class="meta">
                                <span class="tags"><br />Tags :
                                    {% for tag in page.tags %}
                                        <a href="{{ base_url }}/tag/{{ tag }}">#{{ tag }}</a>
                                    {% endfor %}
                                </span>
                            </p>
                            {{ page.excerpt }}
                        </article>
                {% endfor %}
               {% else %}
            <!-- single page -->
            <article>
                {{ content }}
            </article>

But I don't see how to change the if statement...

Any idea ? Thanks :)

bricebou commented 10 years ago

Hey Dan,

After searching inside picotags plugin, I've spent some time inside my theme index.html and on both pico and twig documentations.

I've managed to solve this issue by using a nested if statement after checking if the current_page array is empty or not. Here is the code structure:

{% if is_front_page %}

    FRONT PAGE

{% elseif current_page is not empty %}

    {% if meta.tags is not empty %}

        BLOG POSTS WITH TAGS

    {% else %}

        BLOG POSTS WITHOUT TAGS

    {% endif %}

{% elseif current_page is empty %}

    {% if meta.title != 'Error 404' %}

        TAG PAGES : list of blog posts tagged with #...

    {% endif %}
{% endif %}

The last {% else %} for single page as proposed in the doc seems to never be taken into account for post without tags ; but maybe it's for other pages ? What do you think ? Should I add this to the doc ?

Thanks again :)

danreeves commented 10 years ago

Yep that looks good. I'll await the PR.

bricebou commented 10 years ago

Dan,

I've updated the documentation with this template structure as an alternative. I hope it suits you and my english isn't too bad. It appears on the pull request https://github.com/DanReeves/picotags/pull/9

See you