trulia/hologram

Sorting categories

saviomuc opened this issue · 7 comments

Hi,

is it possible to sort categories? I didn't find out how the logic for that works.

Cheers

I believe they are already sorted alphabetically? For Trulia's styleguide the header has hardcoded links to the category pages and we order those as we wish.

Actually, categories seem to appear in the order that they get created.

I was able to sort the categories by adding this to my _header.html file for the styleguide, which sorts alphabetically by category name (I don't use ruby regularly, so if there's a better way to sort, please correct me).

<% @categories = @categories.sort { |a,b| a[0].downcase <=> b[0].downcase } %>

This seems like a reasonable way to do it to me.

@creativecoder Thanks for that. Any ideas on how to control the ordering? I really don't want by creation date or alphabetical – manual is the way I need!

You can create modify the _header.html file (inside hologram's assets folder) and hard code the category links in the desired order. Would this work for what you're wanting to do?

@jdcantrell Sure, that works I guess. It'd be nice to have this more dynamic as an option in the config perhaps, or even use the index: to be an optional list as well, e.g., index: intro, elements, components, brand etc.

Thanks!