categories in mixed (original) case *as well as* downcase #1739

Closed
paul-hammant opened this Issue Nov 20, 2013 · 10 comments

6 participants

@paul-hammant

With ref to: 73ca35e

It would be awesome to have both the downcase that happened after #842 AND the original case of the category. Why? Then this would be possible, the world would look pretty again:

<a href="/all_your_scm_are_belong_to_us">All your SCM are belong to us</a>

I suggest something like post.categoriesOrigCase in additon to post.categories

-ph

@parkr
Jekyll member

How would you separate them?

@parkr
Jekyll member

category.link vs category.id vs category.name?

@mattr-
Jekyll member

Perhaps category.slug as the lowercase version and category.name as the original case of the category?

@paul-hammant

I'm easy as to how you guys implement it. I'd just prefer to be able to have a choice for presenting in Liquid as I did before commit 73ca35e :)

@MartinThoma

category.slug as the lowercase version (that can be used for the url) and category.name for the displayed text seem to be a good idea, because people might know "Post slug" from Wordpress (source).

Also, category.link seems to be not a good idea, because it is not obvious if this is an absolute URL, a relative URL or only the slug.

@paul-hammant

I got mixed case back again with some JavaScript hackery. http://paulhammant.com/categories.html

<script type="text/javascript">
  function fixupText(attr) {(
    $("." + attr).each(function() {
      var textNode = $(this);
      textNode.html(textNode.text().replace(/(?:^|\s)\w/g, function(match) {
       return match.toUpperCase();
      }).replace("Mvc", "MVC").replace("Nosql", "NoSQL").replace("-side", "-Side").replace("Branch By Abstraction, Etc", "Branch by Abstraction, etc").replace("Ui ", "UI ").replace("Devops", "DevOPS").replace("[", "<span>").replace("]", "</span>"));
    textNode.removeClass(attr);
  });
}  
</script>

and classes added to pertinent anchors and h2s.

@mhulse

How would you separate them?

<my-2-cents>

My take on naming conventions:

  1. category.label === Human readable (humanized) version, like "I am a Duck".
  2. category.name === Geek version, like "i-am-a-duck" or "i_am_a_duck" (depends on context/needs of internal system).

An alternative to categroy.name might be category.title.

To me, a slug is a url-friendly version of a string. Most slug-generating methods/functions I've used will strip common words (like "a" or "the"). category.slug is still a good one to use, but I'd typically expect the common words to be removed. Using "slug" over "link" is definitely the better route to take here. 👍

Other ways I've seen an "original" string stored is to have a "raw" property. Like category.raw or category.name_raw.

</my-2-cents>

@manuelgruber

Is anybody working on that?

@parkr
Jekyll member

@manuelgruber No, not right now!

@yous yous added a commit to yous/jekyll that referenced this issue Jul 5, 2014
@yous yous Use category in downcase only for URL (Resolves #1739) d63cf48
@yous yous added a commit to yous/jekyll that referenced this issue Aug 1, 2014
@yous yous Use category in downcase only for URL (Resolves #1739) f76f59f
@yous yous added a commit to yous/jekyll that referenced this issue Aug 2, 2014
@yous yous Use category in downcase only for URL (Resolves #1739) 7b294bb
@yous yous added a commit to yous/jekyll that referenced this issue Aug 7, 2014
@yous yous Use category in downcase only for URL (Resolves #1739) 3768d90
@parkr
Jekyll member

Tracking in #2977.

@parkr parkr closed this Nov 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment