alexgaribay / octoflat

An Octopress theme based off Twitter Bootstrap v2 and Designmodo's Flat-UI
202 stars 52 forks source link

Title case tags don't work #8

Closed dahoo closed 10 years ago

dahoo commented 11 years ago

You can use {{ category | category_link }} to get the correct link, but you have to adjust the CSS as well.

alexgaribay commented 11 years ago

If you want title case on a tag name, use {{ category | titlecase }}.

dahoo commented 11 years ago

I could do that, but I don't want title case tags all the time. To avoid 404 pages (as I got), I thought, using the generated link would be cleaner and safer.

alexgaribay commented 11 years ago

Using category_link, however, does not allow to me use the hover-over badge effect that is currently in the theme. I tried to copy exactly what the category_generator.rb plugin does for generating a category link.

w0rd-driven commented 11 years ago

Here's what I changed in category_generator.rb Line 176: "#{category}" # JSB: Changed for octoflat theme

I then reverted _includes\post\categories.html and manually corrected _includes\article with {{ post.categories | category_links }}.

In the process of responding I wanted something a little more clean. I changed octopress_filters.rb to include stringex and created this function at the bottom:

Returns the output of the stringex to_url

def to_url(input) input.to_url end

Then in categories and articles I changed the href section to "category | to_url". Neither approach feels terribly clean but they should work. The approach I went with was the second option because it opens up stringex to be used in more places.

Lastly, I caveat all of this by saying I'm a noob and a Ruby noob at that too. A lot already exists but luckily this was a simple enough change. Thanks for bringing this up as I was wondering why my other theme had lowercase proper urls while this one adhered to the title cased tags I have in posts.

w0rd-driven commented 11 years ago

Should've remembered Github would mangle the liquid markup. Basically I wrapped the badge span around the anchor text. The category_index include used by category_generator uses the category_links function call so this approach has the effect of unifying the badge. I wasn't sure if that was an oversight or on purpose.

alexgaribay commented 10 years ago

Tags can now be made in any type of case. The links in the tag will use lowercase now. I think this solves your issue.