-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
80 lines (68 loc) · 2.44 KB
/
index.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
---
layout: default
tab: home
---
<h3>{{ site.posts | size }} articles on many different topics! :cat:</h3>
<a id="random-article-link" href="javascript:void(0)">Take me to a random article! :slightly_smiling_face:</a>
<!-- collecting all tags to make links to tag pages.
Wish I could make it in a more functional style :( I miss you map, filter and friends :( -->
{% assign tags = "" | split: "," %}
{% for post in site.posts %}
{% assign tags = tags | concat: post.tags %}
{% endfor %}
{% assign tags = tags | uniq %}
<!-- Print tags with links -->
<h3>Tags:
<span class="tag-toggle" id="tag-toggle" onclick="tagToggle()">...+...</span>
<div id="tag-links" class="tag-links">
{% for tag in tags%}
<a href="/tags/{{tag}}.html">{{tag}}</a>
{% endfor %}
</div>
</h3>
<!-- Simple script for tag functionality on mobile units -->
<script>
function tagToggle() {
// probably better ways. I'm lazy af
const activePattern = "...+...";
const links = document.getElementById("tag-links");
const toggleBtn = document.getElementById("tag-toggle");
const isActive = activePattern === toggleBtn.innerHTML;
if (isActive) {
toggleBtn.innerHTML = "...-...";
links.style = "display: inline-block;";
}
else {
toggleBtn.innerHTML = activePattern;
links.style = "display: none;";
}
}
</script>
<hr />
<!-- Posts -->
{% for post in paginator.posts %}
{% include postlisting.html title=post.title date=post.date url=post.url excerpt=post.excerpt %}
<hr />
{% endfor %}
<br />
<br />
<!-- Next page navigation -->
<div class="page-navigation">
{% if 1 != paginator.page %}<a href="{{paginator.previous_page_path}}">←</a>{% endif %}
<pre> {{paginator.page}} / {{paginator.total_pages}} </pre>
{% if paginator.total_pages != paginator.page %}<a href="{{paginator.next_page_path}}">→</a>{% endif %}
</div>
<script src="https://cdn.commento.io/js/count.js"></script>
<script>
// Little snippet I originally made for AITales to get a random article
document.getElementById("random-article-link").onclick = function() {
{% for post in site.posts %}
{% if page.url != post.url %}
{% assign urls = urls | append: "'" | append: post.url | append: "', " %}
{% endif %}
{% endfor %}
const posts = [{{urls}}].slice(0, -1);
const randomPost = posts[Math.floor(Math.random() * posts.length)];
window.open(randomPost, '_self');
}
</script>