-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
72 lines (65 loc) · 1.98 KB
/
index.html
File metadata and controls
72 lines (65 loc) · 1.98 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
layout: nav
title: Blog
---
<!--
{% for tag in site.tags %}
<a href="https://ihybrd.github.io/index.html?tag={{ tag[0] }}">{{ tag[0] }}<a/>
{% endfor %}
-->
<div id="content_area"></div>
<script>
// Function to get URL parameter
function getParameterByName(name) {
const url = new URL(window.location.href);
return url.searchParams.get(name);
}
// generating navigation bar
// get value of parameter tag, tags are used as nav/category here
var content_area = document.getElementById('content_area');
// generating the content
if (tag_value) { // if has tag value, only display post with tags
{% for tag in site.tags %}
if ("{{ tag[0] }}" == tag_value) {
{% for post in tag[1] %}
var li = document.createElement('li');
var a2 = document.createElement("a");
a2.href = "{{ post.url }}";
a2.innerText = "{{ post.title }}";
var normalTextNode = document.createTextNode(' - {{ post.date | date: "%-d %b %Y" }}');
li.appendChild(a2);
li.appendChild(normalTextNode);
content_area.appendChild(li);
{% endfor %}
}
{% endfor %}
} else { // else display all
{% for post in site.posts %}
var li = document.createElement('li');
var a2 = document.createElement("a");
a2.href = "{{ post.url }}";
a2.innerText = "{{ post.title }}";
var normalTextNode = document.createTextNode(' - {{ post.date | date: "%-d %b %Y" }}');
li.appendChild(a2);
li.appendChild(normalTextNode);
content_area.appendChild(li);
{% endfor %}
}
</script>
<!--
{% for tag in site.tags %}
<h3>{{ tag[0] }}</h3>
<ul>
{% for post in tag[1] %}
<li><a href="{{ post.url }}">{{ post.title }}</a> - {{ post.date | date: "%-d %b %Y" }}</li>
{% endfor %}
</ul>
{% endfor %}
<ul>
{% for post in site.posts %}
<li>
<a href="{{ post.url }}">{{ post.title }}</a> - {{ post.date | date: "%-d %b %Y" }}
</li>
{% endfor %}
</ul>
-->