Skip to content

Commit 8045d5c

Browse files
committed
Possible Fix
1 parent ade8f3f commit 8045d5c

6 files changed

Lines changed: 176 additions & 12 deletions

File tree

_config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,10 @@ jekyll-archives:
224224
permalinks:
225225
tag: /tags/:name/
226226
category: /categories/:name/
227+
228+
# Define your custom order for specific parents
229+
sub_category_orders:
230+
"HackTheBox Machines": # Change this to your actual category name
231+
- "HTB Easy"
232+
- "HTB Medium"
233+
- "HTB Hard"

_layouts/categories.html

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
---
2+
layout: page
3+
# All the Categories of posts
4+
---
5+
6+
{% include lang.html %}
7+
8+
{% assign HEAD_PREFIX = 'h_' %}
9+
{% assign LIST_PREFIX = 'l_' %}
10+
11+
{% assign group_index = 0 %}
12+
13+
{% assign sort_categories = site.categories | sort %}
14+
15+
{% for category in sort_categories %}
16+
{% assign category_name = category | first %}
17+
{% assign posts_of_category = category | last %}
18+
{% assign first_post = posts_of_category | first %}
19+
20+
{% if category_name == first_post.categories[0] %}
21+
{% assign sub_categories = '' | split: '' %}
22+
23+
{% for post in posts_of_category %}
24+
{% assign second_category = post.categories[1] %}
25+
{% if second_category %}
26+
{% unless sub_categories contains second_category %}
27+
{% assign sub_categories = sub_categories | push: second_category %}
28+
{% endunless %}
29+
{% endif %}
30+
{% endfor %}
31+
32+
{% comment %} CUSTOM SORTING LOGIC START {% endcomment %}
33+
{% assign custom_order = site.sub_category_orders[category_name] %}
34+
35+
{% if custom_order %}
36+
{% assign sorted_subs = "" | split: "" %}
37+
{% comment %} 1. Add specific ones in order {% endcomment %}
38+
{% for ordered_name in custom_order %}
39+
{% if sub_categories contains ordered_name %}
40+
{% assign sorted_subs = sorted_subs | push: ordered_name %}
41+
{% endif %}
42+
{% endfor %}
43+
{% comment %} 2. Add anything else alphabetically {% endcomment %}
44+
{% assign remaining_subs = "" | split: "" %}
45+
{% for sub in sub_categories %}
46+
{% unless custom_order contains sub %}
47+
{% assign remaining_subs = remaining_subs | push: sub %}
48+
{% endunless %}
49+
{% endfor %}
50+
{% assign remaining_subs = remaining_subs | sort %}
51+
{% for sub in remaining_subs %}
52+
{% assign sorted_subs = sorted_subs | push: sub %}
53+
{% endfor %}
54+
{% assign sub_categories = sorted_subs %}
55+
{% else %}
56+
{% assign sub_categories = sub_categories | sort %}
57+
{% endif %}
58+
{% comment %} CUSTOM SORTING LOGIC END {% endcomment %}
59+
60+
{% assign sub_categories_size = sub_categories | size %}
61+
62+
<div class="card categories">
63+
<div
64+
id="{{ HEAD_PREFIX }}{{ group_index }}"
65+
class="card-header d-flex justify-content-between hide-border-bottom"
66+
>
67+
<span class="ms-2">
68+
<i class="far fa-folder{% if sub_categories_size > 0 %}-open{% endif %} fa-fw"></i>
69+
70+
{% capture _category_url %}/categories/{{ category_name | slugify | url_encode }}/{% endcapture %}
71+
<a href="{{ _category_url | relative_url }}" class="mx-2">{{ category_name }}</a>
72+
73+
{% assign top_posts_size = site.categories[category_name] | size %}
74+
<span class="text-muted small font-weight-light">
75+
{% if sub_categories_size > 0 %}
76+
{{ sub_categories_size }}
77+
{% if sub_categories_size > 1 %}
78+
{{
79+
site.data.locales[lang].categories.category_measure.plural
80+
| default: site.data.locales[lang].categories.category_measure
81+
}}
82+
{% else %}
83+
{{
84+
site.data.locales[lang].categories.category_measure.singular
85+
| default: site.data.locales[lang].categories.category_measure
86+
}}
87+
{% endif -%}
88+
,
89+
{% endif %}
90+
91+
{{ top_posts_size }}
92+
93+
{% if top_posts_size > 1 %}
94+
{{
95+
site.data.locales[lang].categories.post_measure.plural
96+
| default: site.data.locales[lang].categories.post_measure
97+
}}
98+
{% else %}
99+
{{
100+
site.data.locales[lang].categories.post_measure.singular
101+
| default: site.data.locales[lang].categories.post_measure
102+
}}
103+
{% endif %}
104+
</span>
105+
</span>
106+
107+
{% if sub_categories_size > 0 %}
108+
<a
109+
href="#{{ LIST_PREFIX }}{{ group_index }}"
110+
data-bs-toggle="collapse"
111+
aria-expanded="true"
112+
aria-label="{{ HEAD_PREFIX }}{{ group_index }}-trigger"
113+
class="category-trigger hide-border-bottom"
114+
>
115+
<i class="fas fa-fw fa-angle-down"></i>
116+
</a>
117+
{% else %}
118+
<span data-bs-toggle="collapse" class="category-trigger hide-border-bottom disabled">
119+
<i class="fas fa-fw fa-angle-right"></i>
120+
</span>
121+
{% endif %}
122+
</div>
123+
{% if sub_categories_size > 0 %}
124+
<div id="{{ LIST_PREFIX }}{{ group_index }}" class="collapse show" aria-expanded="true">
125+
<ul class="list-group">
126+
{% for sub_category in sub_categories %}
127+
<li class="list-group-item">
128+
<i class="far fa-folder fa-fw"></i>
129+
130+
{% capture _sub_ctg_url %}/categories/{{ sub_category | slugify | url_encode }}/{% endcapture %}
131+
<a href="{{ _sub_ctg_url | relative_url }}" class="mx-2">{{ sub_category }}</a>
132+
133+
{% assign posts_size = site.categories[sub_category] | size %}
134+
<span class="text-muted small font-weight-light">
135+
{{ posts_size }}
136+
137+
{% if posts_size > 1 %}
138+
{{
139+
site.data.locales[lang].categories.post_measure.plural
140+
| default: site.data.locales[lang].categories.post_measure
141+
}}
142+
{% else %}
143+
{{
144+
site.data.locales[lang].categories.post_measure.singular
145+
| default: site.data.locales[lang].categories.post_measure
146+
}}
147+
{% endif %}
148+
</span>
149+
</li>
150+
{% endfor %}
151+
</ul>
152+
</div>
153+
{% endif %}
154+
</div>
155+
{% assign group_index = group_index | plus: 1 %}
156+
{% endif %}
157+
{% endfor %}

_posts/2025-11-16-htboutbound.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Outbound Writeup
33
date: 2025-11-16
4-
categories: [HackTheBox Challenges, HTB Easy]
5-
tags: [htb, challenge, easy]
6-
description: HackTheBox Outbound Easy Challenge Writeup
4+
categories: [HackTheBox Machines, HTB Easy]
5+
tags: [htb, machine, easy]
6+
description: HackTheBox Outbound Easy Machine Writeup
77
media_subpath: /assets/img/htb/outbound/
88
---
99

_posts/2025-11-30-htbera.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Era Writeup
33
date: 2025-11-30
4-
categories: [HackTheBox Challenges, HTB Medium]
5-
tags: [htb, challenge, medium]
6-
description: HackTheBox Era Medium Challenge Writeup
4+
categories: [HackTheBox Machines, HTB Medium]
5+
tags: [htb, machine, medium]
6+
description: HackTheBox Era Medium Machine Writeup
77
media_subpath: /assets/img/htb/era/
88
---
99

_posts/2026-02-11-htbimagery.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Imagery Writeup
33
date: 2026-02-11
4-
categories: [HackTheBox Challenges, HTB Medium]
5-
tags: [htb, challenge, medium]
6-
description: HackTheBox Imagery Medium Challenge Writeup
4+
categories: [HackTheBox Machines, HTB Medium]
5+
tags: [htb, machine, medium]
6+
description: HackTheBox Imagery Medium Machine Writeup
77
media_subpath: /assets/img/htb/imagery/
88
---
99

_posts/2026-03-02-htbguardian.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
title: Guardian Writeup
33
date: 2026-03-02
4-
categories: [HackTheBox Challenges, HTB Hard]
5-
tags: [htb, challenge, hard]
6-
description: HackTheBox Guardian Hard Challenge Writeup
4+
categories: [HackTheBox Machines, HTB Hard]
5+
tags: [htb, machine, hard]
6+
description: HackTheBox Guardian Hard Machine Writeup
77
media_subpath: /assets/img/htb/guardian/
88
---
99

0 commit comments

Comments
 (0)