trulia / hologram

A markdown based documentation system for style guides.
http://trulia.github.io/hologram
Other
2.16k stars 199 forks source link

Sorting categories #200

Closed saviomuc closed 9 years ago

saviomuc commented 9 years ago

Hi,

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

Cheers

jdcantrell commented 9 years ago

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.

creativecoder commented 9 years ago

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 } %>
jdcantrell commented 9 years ago

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

ryanmclaughlin commented 8 years ago

@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!

jdcantrell commented 8 years ago

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?

ryanmclaughlin commented 8 years ago

@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!

mstenquist commented 8 years ago

+1