Lewiscowles1986 / Jekyll-Improved-Category-Pages-Plugin

I Believe a better way of generating category pages for Jekyll
GNU General Public License v2.0
5 stars 2 forks source link

Added helper variable, removed extra slash #1

Closed juzraai closed 8 years ago

juzraai commented 8 years ago

category_root variable helps layout to decide whether to render a category list or a post list - without knowing the title of the category list page (old version). This way, title of the category list can be edited at only one place. :)

Also there was an extra slash in taxonomy link which produced a "/categories//category-name/" like URL.

Awesome plugin anyway! :)

Lewiscowles1986 commented 8 years ago

This looks promising, I take it you assign category_root; or is it a jekyll feature?

The other question I have is which versions of Jekyll this has been tested up to and what config.yml looks like in the case you have two slashes?

juzraai commented 8 years ago

This looks promising, I take it you assign category_root; or is it a jekyll feature?

I assigned it :) in category_pages.rb on lines 19 and 22.

which versions of Jekyll this has been tested up to and what config.yml looks like in the case you have two slashes?

I used the default config.yml:

title: Your awesome title
email: your-email@domain.com
description: ...
baseurl: ""
url: "http://yourdomain.com"
markdown: kramdown 

With Jekyll v3.1.6 and your code, the generated HTML looks like this:

<ul class="posts">
    <h2><a href="/categories//jekyll/">jekyll</a></h2>
    <h2><a href="/categories//update/">update</a></h2>
</ul>   

But now I've tried with Jekyll v2.3.5, and here your code works well:

<ul class="posts">
    <h2><a href="/categories/jekyll/">jekyll</a></h2>
    <h2><a href="/categories/update/">update</a></h2>
</ul>

Strange... my code fixes double slash in Jekyll v3.1.6 but creates a mess in v2.3.5.

I've just added a new commit which uses Liquid filters to add the slash, and then replace double slash with a single one. I tested it in both Jekyll v3.1.6 and v2.3.5, it works well:

<h2><a href="{{ page.url | prepend: base_url | replace: "/index.html", "" | append: "/" | replace: "//", "/" }}{{ taxonomy }}/">{{ taxonomy }}</a></h2>
Lewiscowles1986 commented 8 years ago

Thank you very much :+1: . It's true, I think I wrote this pre 3.x :wink: