Skip to content

Commit

Permalink
Use sort_natural instead of custom-logic (mmistakes#2756)
Browse files Browse the repository at this point in the history
  • Loading branch information
gamue committed Feb 6, 2021
1 parent 35b63ae commit 6ddffe3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
11 changes: 2 additions & 9 deletions _includes/category-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,12 @@
{% endcase %}

{% if site.category_archive.path %}
{% comment %}
<!-- Sort alphabetically regardless of case e.g. a B c d E -->
<!-- modified from http://www.codeofclimber.ru/2015/sorting-site-tags-in-jekyll/ -->
{% endcomment %}
{% capture page_categories %}{% for category in page.categories %}{{ category | downcase }}|{{ category }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %}
{% assign category_hashes = page_categories | split: ',' | sort %}
{% assign categories_sorted = page.categories | sort_natural %}

<p class="page__taxonomy">
<strong><i class="fas fa-fw fa-folder-open" aria-hidden="true"></i> {{ site.data.ui-text[site.locale].categories_label | default: "Categories:" }} </strong>
<span itemprop="keywords">
{% for hash in category_hashes %}
{% assign keyValue = hash | split: '|' %}
{% capture category_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %}
{% for category_word in categories_sorted %}
<a href="{{ category_word | slugify | prepend: path_type | prepend: site.category_archive.path | relative_url }}" class="page__taxonomy-item" rel="tag">{{ category_word }}</a>{% unless forloop.last %}<span class="sep">, </span>{% endunless %}
{% endfor %}
</span>
Expand Down
11 changes: 2 additions & 9 deletions _includes/tag-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,12 @@
{% endcase %}

{% if site.tag_archive.path %}
{% comment %}
<!-- Sort alphabetically regardless of case e.g. a B c d E -->
<!-- modified from http://www.codeofclimber.ru/2015/sorting-site-tags-in-jekyll/ -->
{% endcomment %}
{% capture page_tags %}{% for tag in page.tags %}{{ tag | downcase }}|{{ tag }}{% unless forloop.last %},{% endunless %}{% endfor %}{% endcapture %}
{% assign tag_hashes = page_tags | split: ',' | sort %}
{% assign tags_sorted = page.tags | sort_natural %}

<p class="page__taxonomy">
<strong><i class="fas fa-fw fa-tags" aria-hidden="true"></i> {{ site.data.ui-text[site.locale].tags_label | default: "Tags:" }} </strong>
<span itemprop="keywords">
{% for hash in tag_hashes %}
{% assign keyValue = hash | split: '|' %}
{% capture tag_word %}{{ keyValue[1] | strip_newlines }}{% endcapture %}
{% for tag_word in tags_sorted %}
<a href="{{ tag_word | slugify | prepend: path_type | prepend: site.tag_archive.path | relative_url }}" class="page__taxonomy-item" rel="tag">{{ tag_word }}</a>{% unless forloop.last %}<span class="sep">, </span>{% endunless %}
{% endfor %}
</span>
Expand Down

0 comments on commit 6ddffe3

Please sign in to comment.