Skip to content

Commit 294a563

Browse files
committed
Fix underscores in the links of tags/categories (cotes2020#199)
1 parent 417b0d3 commit 294a563

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

_includes/panel.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
<div class="access">
1212

1313
{% include update-list.html %}
14-
14+
1515
{% if update_list.size > 0 %}
16-
16+
1717
<div id="access-lastmod" class="post">
1818
<span>{{- site.data.label.panel.lastmod -}}</span>
1919
<ul class="post-content pl-0 pb-1 ml-1 mt-2">
@@ -27,7 +27,7 @@
2727

2828
</ul>
2929
</div> <!-- #access-lastmod -->
30-
30+
3131
{% endif %}
3232

3333
{% include trending-tags.html %}
@@ -36,10 +36,10 @@
3636
<div id="access-tags">
3737
<span>{{- site.data.label.panel.trending_tags -}}</span>
3838
<div class="d-flex flex-wrap mt-3 mb-1 mr-3">
39-
40-
{% for tag in trending_tags %}
41-
{% capture url %}/tags/{{ tag | downcase | url_encode }}/{% endcapture %}
42-
<a class="post-tag" href="{{ url | relative_url }}">{{ tag | replace: '-', ' ' }}</a>
39+
40+
{% for tag_name in trending_tags %}
41+
{% assign url = tag_name | slugify | url_encode | prepend: "/tags/" | append: "/" %}
42+
<a class="post-tag" href="{{ url | relative_url }}">{{ tag_name }}</a>
4343
{% endfor %}
4444

4545
</div>

_includes/search-results.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ <h4 class="text-muted mb-4">{{ site.data.label.panel.trending_tags }}</h4>
1313
{% include trending-tags.html %}
1414

1515
{% for tag in trending_tags %}
16-
{% capture url %}/tags/{{ tag | downcase | url_encode }}/{% endcapture %}
16+
{% capture url %}/tags/{{ tag | slugify | url_encode }}/{% endcapture %}
1717
<a class="post-tag" href="{{ url | relative_url }}">{{ tag | replace: '-', ' ' }}</a>
1818
{% endfor %}
1919

2020
</div>
2121
<div id="search-results" class="d-flex flex-wrap justify-content-center text-muted mt-3"></div>
2222
</div>
23-
</div>
23+
</div>

_includes/trending-tags.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
{% assign size = tag | last | size %}
1616
{% assign size_list = size_list | push: size %}
1717

18-
{% assign tag_str = tag | first | replace: " ", "-" | append: "::" | append: size %}
18+
{% assign tag_str = tag | first | append: "::" | append: size %}
1919
{% assign tag_list = tag_list | push: tag_str %}
2020
{% endfor %}
2121

_layouts/categories.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
{% else %}
4747
<i class="far fa-folder fa-fw"></i>
4848
{% endif %}
49-
<a href="{{ site.baseurl }}/categories/{{ category_name | replace: ' ', '-' | downcase | url_encode }}/"
49+
<a href="{{ site.baseurl }}/categories/{{ category_name | slugify | url_encode }}/"
5050
class="ml-1 mr-2">
5151
{{ category_name }}
5252
</a>
@@ -85,7 +85,7 @@
8585
{% for sub_category in sub_categories %}
8686
<li class="list-group-item">
8787
<i class="far fa-folder fa-fw"></i>
88-
<a href="{{ site.baseurl }}/categories/{{ sub_category | replace: ' ', '-' | downcase | url_encode }}/"
88+
<a href="{{ site.baseurl }}/categories/{{ sub_category | slugify | url_encode }}/"
8989
class="ml-1 mr-2">{{ sub_category }}</a>
9090
{% assign posts_size = site.categories[sub_category] | size %}
9191
<span class="text-muted small font-weight-light">{{ posts_size }}

_layouts/post.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ <h1 data-toc-skip>{{ page.title }}</h1>
7373
<div class="post-meta mb-3">
7474
<i class="far fa-folder-open fa-fw mr-1"></i>
7575
{% for category in page.categories %}
76-
<a href='{{ site.baseurl }}/categories/{{ category | replace: ' ', '-' | downcase | url_encode }}/'>{{ category }}</a>
76+
<a href='{{ site.baseurl }}/categories/{{ category | slugify | url_encode }}/'>{{ category }}</a>
7777
{%- unless forloop.last -%}, {%- endunless -%}
7878
{% endfor %}
7979
</div>
@@ -84,7 +84,7 @@ <h1 data-toc-skip>{{ page.title }}</h1>
8484
<div class="post-tags">
8585
<i class="fa fa-tags fa-fw mr-1"></i>
8686
{% for tag in page.tags %}
87-
<a href="{{ site.baseurl }}/tags/{{ tag | replace: ' ', '-' | downcase | url_encode }}/"
87+
<a href="{{ site.baseurl }}/tags/{{ tag | slugify | url_encode }}/"
8888
class="post-tag no-text-decoration" >
8989
{{- tag -}}
9090
</a>

_layouts/tags.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
{% for t in sorted_tags %}
2121
<div>
22-
<a class="tag" href="{{ site.baseurl }}/tags/{{ t | replace: ' ', '-' | downcase | url_encode }}/">{{ t }}<span class="text-muted">{{ site.tags[t].size }}</span></a>
22+
<a class="tag" href="{{ site.baseurl }}/tags/{{ t | slugify | url_encode }}/">{{ t }}<span class="text-muted">{{ site.tags[t].size }}</span></a>
2323
</div>
2424
{% endfor %}
2525

0 commit comments

Comments
 (0)