-
Notifications
You must be signed in to change notification settings - Fork 265
/
Copy pathcategory.html
48 lines (45 loc) · 1.35 KB
/
category.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<article class="post">
<header class="post-header home">
<div class="post-title">Category - <span id='category-name'></span></div>
</header>
<div class="post-content">
{%- if site.posts.size > 0 -%}
<ul class="post-list">
{%- for post in site.posts -%}
<li class="post-list-item post-category-{{post.categories}}">
<!-- {%- assign date_format = site.date_format | default: "%b %-d, %Y" -%} -->
{%- assign date_format = "%Y/%m/%d" -%}
<span class="post-date">{{ post.date | date: date_format }}</span>
<a class="post-link" href="{{ post.url | relative_url }}">
{{ post.title | escape }}
</a>
{%- if site.show_excerpts -%}{{ post.excerpt }}{%- endif -%}
</li>
{%- endfor -%}
</ul>
{%- endif -%}
</div>
</article>
<script src="/public/js/jquery-3.4.1.slim.min.js"></script>
<script>
function removeCategory() {
if (window.location.hash) {
let hash = window.location.hash.substring(1);
$('#category-name').text(hash.substring(0, 1).toUpperCase() + hash.substring(1));
let category_class = '.post-category-' + hash;
let items = $('.post-list-item').each((i, e) => {
if (!$(e).hasClass('post-category-' + hash)) {
$(e).hide();
} else {
$(e).show();
}
});
}
}
$(window).on('hashchange', () => {
removeCategory();
});
$(document).ready(() => {
removeCategory();
})
</script>