Skip to content
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

Inject a {taxon}_{type}_index_permalinks for every type of taxonomy index created #197

Merged
merged 2 commits into from Feb 6, 2015

Conversation

simensen
Copy link
Member

This replaces #192. I think this is a simpler approach and results in less code needing to be written.

Usage would be either:

            {% if page.tags %}
                <p class="tags">Tagged with
                    {% for tag in page.tags %}
                        <a class="tag" href="{{ site.url }}/{{ page.tag_html_index_permalinks[tag] }}">{{ tag }}</a>{% if not loop.last %}, {% endif %}
                    {% endfor %}
                </p>
            {% endif %}

... or

            {% if page.tags %}
                <p class="tags">Tagged with
                    {% for tag,permalink in page.tag_html_index_permalinks %}
                        <a class="tag" href="{{ site.url }}/{{ permalink }}">{{ tag }}</a>{% if not loop.last %}, {% endif %}
                    {% endfor %}
                </p>
            {% endif %}

Either would work.

The nice things over #192 are that 1) it only creates these for taxonomies for which an index page even exists and 2) it accounts for the fact that you might have several index pages (like an Atom/RSS feed vs an HTML one). It also does not mess with anything that would require changes to the config / extension meta programming stuff and we do not have to find a way to extract the URL building stuff.

ping @WyriHaximus

@simensen
Copy link
Member Author

For consistency I'm also considering adding this to this PR:

<?php

            if (0 !== strpos($permalink, '/')) {
                $permalink = '/'.$permalink;
            }

Basically, most of the other URL's generated including a leading / so that things like {{ site.url }}{{ page.url }} work w/o having a / in the middle.

Thoughts?

@davedevelopment
Copy link
Contributor

I don't know much about all of this, but I can't spot any silly mistakes, so 👍 :)

@WyriHaximus
Copy link
Member

Looks good to me, including the trailing / 👍 .

simensen added a commit that referenced this pull request Feb 6, 2015
Inject a {taxon}_{type}_index_permalinks for every type of taxonomy index created
@simensen simensen merged commit 34bbca4 into sculpin:master Feb 6, 2015
@simensen
Copy link
Member Author

simensen commented Feb 6, 2015

Thanks for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants