New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify year output logic in post_index #166

merged 2 commits into from Aug 7, 2015


None yet
2 participants

andreykurenkov commented Aug 5, 2015

While modifying the base theme to support tags and multiple categories, the year output on post_index got messed up multiple times due to it assuming all posts in site.posts will be posted on the post_index page (no if statements will be added or such). My post_index is modified in more different ways, but I think this particular change would benefit people forking the code in the future.

{% for post in site.posts %}  
    {% unless %}
        <h3>{{ | date: '%Y' }}</h3>
    {% else %}
        {% capture year %}{{ | date: '%Y' }}{% endcapture %}
        {% capture nyear %}{{ | date: '%Y' }}{% endcapture %}
        {% if year != nyear %}
            <h3>{{ | date: '%Y' }}</h3>
        {% endif %}
    {% endunless %}
{% capture written_year %}'None'{% endcapture %}
{% for post in site.posts %}  
    {% capture year %}{{ | date: '%Y' }}{% endcapture %}
    {% if year != written_year %}
        <h3>{{ | date: '%Y' }}</h3>
    {% endif %}
    {% capture written_year %}{{ year }}{% endcapture %}

This comment has been minimized.

Show comment
Hide comment

mmistakes Aug 7, 2015




mmistakes commented Aug 7, 2015


mmistakes added a commit that referenced this pull request Aug 7, 2015

Merge pull request #166 from andreykurenkov/improve_year_output
Simplify year output logic in post_index

@mmistakes mmistakes merged commit e7489a1 into mmistakes:master Aug 7, 2015

MiteshShah added a commit to MiteshShah/ that referenced this pull request Aug 8, 2015

jluccisano added a commit to jluccisano/ that referenced this pull request May 6, 2017

antonizoon pushed a commit to antonizoon/ that referenced this pull request Jul 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment