Skip to content

Commit 1ad5279

Browse files
authored
Merge branch 'develop' into master
2 parents 04f180c + f165327 commit 1ad5279

File tree

7 files changed

+128
-18
lines changed

7 files changed

+128
-18
lines changed

_config.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Site settings
99
title: Ben's Realm
1010
11-
description: >-
11+
description: The internet home for all of my personal projects and thoughts.
1212
baseurl: "" # the subpath of your site, e.g. /blog
1313
url: "https://www.bengodfrey.net" #interwebz
1414
twitter_username: BenJetson
@@ -35,6 +35,11 @@ permalink: /blog/:year/:month/:day-:title
3535
paginate: 6
3636
paginate_path: "/blog/page:num/"
3737

38+
# Counter settings
39+
counter:
40+
namespace: bengodfrey.net
41+
key: visitors
42+
3843
# Plugins used for production.
3944
# WARNING: any changes to plugins should be made to _config_dev.yml also!
4045
plugins:

_includes/footer.html

+18-13
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,27 @@ <h4>{{site.title}}</h4>
77
</div>
88
<div class="col-sm-12 col-md-3 d-print-none">
99
<h5>Follow me!</h5>
10-
<img src="https://dummyimage.com/50x50/f55/fff&text=g" alt="google+" />
11-
<img
12-
src="https://dummyimage.com/50x50/2bcaff/0011ff&text=t"
13-
alt="twitter"
14-
/>
15-
<img src="https://dummyimage.com/50x50/444/fff&text=gh" alt="github" />
10+
<div class="social-grid">
11+
<a class="social-icon" href="https://github.com/benjetson">
12+
<i class="bi bi-github"></i>
13+
<span class="visually-hidden">GitHub</span>
14+
</a>
15+
<a class="social-icon" href="https://twitter.com/benjetson">
16+
<i class="bi bi-twitter"></i>
17+
<span class="visually-hidden">Twitter</span>
18+
</a>
19+
<a class="social-icon" href="https://www.linkedin.com/in/bfgodfrey">
20+
<i class="bi bi-linkedin"></i>
21+
<span class="visually-hidden">LinkedIn</span>
22+
</a>
23+
</div>
1624
</div>
17-
<div class="col-sm-12 col-md-3 py-3 d-print-none">
18-
<img
19-
src="https://www.free-website-hit-counter.com/c.php?d=5&id=109636&s=8"
20-
class="img-fluid"
21-
id="hitCounter"
22-
/>
25+
<div class="col-sm-12 col-md-3 d-print-none">
26+
<h5>Pageviews</h5>
27+
<div id="counter"></div>
2328
</div>
2429
</div>
25-
<div class="row pb-3">
30+
<div class="row pt-4 pb-3">
2631
<div class="col">
2732
<h6>
2833
&copy; {{ "now" | date: "%Y" }} Ben Godfrey. All rights reserved.

_includes/scripts.html

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,13 @@
1616
crossorigin="anonymous"
1717
></script>
1818
{% endif %} {% if page.recaptcha %}
19-
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
19+
<script async defer src="https://www.google.com/recaptcha/api.js"></script>
2020
{% endif %}
21+
<script>
22+
window.counter = {
23+
namespace: "{{site.counter.namespace}}",
24+
key: "{{site.counter.key}}",
25+
value: null,
26+
};
27+
</script>
28+
<script async defer src="{{site.url}}/js/counts.js"></script>

_sass/custom/styles/_footer.scss

+46-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,50 @@
44
// Styles for elements in the footer.
55
//
66

7-
img#hitCounter {
8-
height: 26px;
9-
width: 110px;
7+
footer {
8+
.social-grid {
9+
display: flex;
10+
flex-direction: row;
11+
flex-wrap: wrap;
12+
13+
.social-icon {
14+
display: block;
15+
margin-right: 1em;
16+
17+
font-size: 32px;
18+
text-align: center;
19+
20+
color: inherit;
21+
}
22+
}
23+
24+
#counter {
25+
margin: 1em 0;
26+
27+
span.digit {
28+
background-color: $black;
29+
font-family: monospace;
30+
font-size: 28px;
31+
font-style: italic;
32+
33+
border: 2px solid $gray-700;
34+
border-radius: 7px;
35+
36+
position: relative;
37+
38+
padding: 0.25em;
39+
padding-right: 0.35em;
40+
margin-right: 1px;
41+
}
42+
43+
span.digit::before {
44+
content: "";
45+
position: absolute;
46+
z-index: 0;
47+
bottom: 50%;
48+
left: 0;
49+
border-bottom: 2px solid rgba($gray-600, 50%);
50+
width: 100%;
51+
}
52+
}
1053
}

js/counts.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
window.counter.update = async () => {
2+
const counter = document.getElementById("counter"),
3+
key = window.counter.key,
4+
namespace = window.counter.namespace;
5+
6+
// Clear existing nodes in the counter.
7+
while (counter.firstChild) counter.removeChild(counter.lastChild);
8+
9+
const res = await fetch(`https://api.countapi.xyz/hit/${namespace}/${key}`);
10+
if (res.status !== 200) {
11+
throw `Failed to hit the counter API; received status ${res.status}.`;
12+
}
13+
14+
const data = await res.json();
15+
if (data.value === undefined) {
16+
throw `Missing counter value!`;
17+
}
18+
19+
let value = data.value;
20+
window.counter.value = value;
21+
22+
// Add an accessible version of the counter, hidden from normal view.
23+
const a11yCounter = document.createElement("p");
24+
a11yCounter.classList.add("visually-hidden");
25+
a11yCounter.innerText = `The current pageview count is ${value}.`;
26+
counter.append(a11yCounter);
27+
28+
while (value > 0) {
29+
const digit = value % 10;
30+
value = Math.floor(value / 10);
31+
32+
const digitNode = document.createElement("span");
33+
digitNode.classList.add("digit");
34+
digitNode.innerText = digit;
35+
36+
// Hide digits from screen readers since their readout would be confusing.
37+
digitNode.setAttribute("aria-hidden", true);
38+
39+
counter.prepend(digitNode);
40+
}
41+
42+
return value;
43+
};
44+
45+
window.addEventListener("load", () => window.counter.update());

scripts/pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[tool.black]
2+
line-length = 80
3+
target-version = ['py38']

scripts/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
black
22
python-frontmatter
33
pre-commit
4+
countapi

0 commit comments

Comments
 (0)