Skip to content

Commit b950f19

Browse files
add tags and categories page
1 parent b413d7c commit b950f19

File tree

8 files changed

+83
-46
lines changed

8 files changed

+83
-46
lines changed

_data/navigation.yml

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
links:
22
- title: Posts
33
url: /
4+
- title: Categories
5+
url: /categories
6+
- title: Tags
7+
url: /tags
48
- title: Search
59
url: /search
610
- title: Linkedin

_layouts/categories.html

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
layout: default
3+
title: Categories
4+
---
5+
6+
<style>
7+
.categories ul {
8+
list-style: none;
9+
}
10+
11+
.categories li {
12+
align-items: center;
13+
display: flex;
14+
justify-content: space-between;
15+
margin-bottom: 0.25rem;
16+
}
17+
18+
.categories li a {
19+
white-space: nowrap;
20+
overflow: hidden;
21+
text-overflow: ellipsis;
22+
text-decoration: none;
23+
}
24+
</style>
25+
26+
<section class="categories">
27+
<h1>{{ page.title }}</h1>
28+
<ul>
29+
{% for category in site.categories %}
30+
<li>
31+
<li><a href="/category/{{ category | first }}/">{{ category[0] }} ({{ category | last | size }})</a></li>
32+
</li>
33+
{% endfor %}
34+
</ul>
35+
</section>

_layouts/search.html

-27
This file was deleted.

_layouts/tag.html

+8-9
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
<section class="posts">
66
<h1>Tag #{{page.tag}}</h1>
7-
<ul>
8-
{% for post in site.posts %}
9-
{% if post.tags contains page.tag %}
10-
<li><a class="post" href="{{ post.url }}">{{ post.title }}</a><time datetime="{{ post.date | date_to_xmlschema }}">{{ post.date | date: "%m-%d-%Y" }}</time></li>
11-
{% endif %}
12-
{% endfor %}
13-
</ul>
14-
15-
</section>
7+
<ul>
8+
{% for post in site.posts %}
9+
{% if post.tags contains page.tag %}
10+
<li><a class="post" href="{{ post.url }}">{{ post.title }}</a><time datetime="{{ post.date | date_to_xmlschema }}">{{ post.date | date: "%m-%d-%Y" }}</time></li>
11+
{% endif %}
12+
{% endfor %}
13+
</ul>
14+
</section>

_layouts/tags.html

+27-9
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,31 @@
33
title: Tags
44
---
55

6-
<section class="posts">
6+
<style>
7+
.tags ul {
8+
list-style: none;
9+
}
10+
11+
.tags li {
12+
margin-bottom: 0.5rem;
13+
margin-right: 0.25rem;
14+
display: inline-block;
15+
}
16+
17+
.tags li a {
18+
white-space: nowrap;
19+
overflow: hidden;
20+
text-overflow: ellipsis;
21+
text-decoration: none;
22+
}
23+
</style>
24+
25+
<section class="tags">
726
<h1>{{ page.title }}</h1>
8-
{% assign tags = site.tags | sort %}
9-
<ul>
10-
{% for tag in tags %}
11-
<li><a href="/tag/{{ tag | first | slugify }}/">{{ tag[0] | replace:'-', ' ' }} ({{ tag | last | size }}){% unless forloop.last %}, {% endunless %}</a></li>
12-
{% endfor %}
13-
</ul>
14-
15-
</section>
27+
{% assign tags = site.tags | sort %}
28+
<ul>
29+
{% for tag in tags %}
30+
<li><a href="/tag/{{ tag | first }}/">{{ tag[0] }} ({{ tag | last | size }}){% unless forloop.last %}, {% endunless %}</a></li>
31+
{% endfor %}
32+
</ul>
33+
</section>

_pages/categories.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
layout: categories
3+
title: Categories
4+
---

_pages/tags.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
layout: tags
3+
title: Tags
4+
---

_sass/_main.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ h1 {
226226
@media screen and (max-width: 45rem) {
227227
header li {
228228
display: inline;
229-
margin-right: 1rem;
229+
margin-right: 0.5rem;
230230
}
231231
.logo {
232232
padding-bottom: 1rem;

0 commit comments

Comments
 (0)