Skip to content

Instantly share code, notes, and snippets.

@matthewcopeland
Created August 29, 2012 00:36
Show Gist options
  • Save matthewcopeland/3505659 to your computer and use it in GitHub Desktop.
Save matthewcopeland/3505659 to your computer and use it in GitHub Desktop.
Adding a category class to your octopress blog so you can attached an icon/color to the cat. two methods
// Or use this method...
//
// E[foo$="bar"]
// an E element whose "foo" attribute value ends exactly with the string "bar"
//
// http://www.w3.org/TR/css3-selectors/#attribute-selectors
a.category[href$="css/"] {
padding-left: 20px;
background: url('your-icon.png') left center no-repeat;
}
// this works really well because you won't need the '/' at the end of your string.
a.category[href*="css"] {
padding-left: 20px;
background: url('your-icon.png') left center no-repeat;
}
# or you could just add a class
# line 146 of category_generator.rb
--- "<a class='category' href='/#{dir}/#{item.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase}/'>#{item}</a>"
+++ "<a class='category #{item}' href='/#{dir}/#{item.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase}/'>#{item}</a>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment