Skip to content

Commit 0ba1b32

Browse files
committed
Reduce hashtag font size and spacing for compact, minimal look on blog
1 parent 98a3a69 commit 0ba1b32

File tree

2 files changed

+101
-1
lines changed

2 files changed

+101
-1
lines changed

_sass/_base.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,10 @@ pre {
626626
}
627627

628628
.hashtag-link {
629+
font-size: 0.85em;
630+
padding: 0.13em 0.7em;
631+
margin-right: 0.15em;
632+
margin-bottom: 0.18em;
629633
display: inline-block;
630634
padding: 0.18em 0.9em;
631635
border-radius: 999px;

blog/index.md

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,54 @@ title: Blog
2828
{% endif %}
2929
</div>
3030

31+
<script>
32+
// Minimal client-side hashtag filter for GitHub Pages
33+
(function() {
34+
function getTagParam() {
35+
const params = new URLSearchParams(window.location.search);
36+
return params.get('tag') ? params.get('tag').toLowerCase() : null;
37+
}
38+
function filterPostsByTag(tag) {
39+
var posts = document.querySelectorAll('.post-list .post-item');
40+
posts.forEach(function(post) {
41+
const tags = post.getAttribute('data-tags') || '';
42+
if (!tag || tags.includes(tag)) {
43+
post.style.display = '';
44+
} else {
45+
post.style.display = 'none';
46+
}
47+
});
48+
}
49+
function highlightActiveTag(tag) {
50+
var links = document.querySelectorAll('.hashtag-link');
51+
links.forEach(function(link) {
52+
var linkTag = link.textContent.replace(/^#/, '').toLowerCase();
53+
if (tag && linkTag === tag) {
54+
link.classList.add('active');
55+
} else {
56+
link.classList.remove('active');
57+
}
58+
});
59+
}
60+
var tag = getTagParam();
61+
if (tag) {
62+
filterPostsByTag(tag);
63+
highlightActiveTag(tag);
64+
}
65+
})();
66+
</script>
67+
68+
<style>
69+
/* Minimal highlight for active hashtag */
70+
.hashtag-link.active {
71+
background: var(--hashtag-hover-bg, #e0e7ef);
72+
color: var(--hashtag-hover-color, #007acc);
73+
border-color: var(--hashtag-hover-border, #b3c7e6);
74+
font-weight: 600;
75+
}
76+
</style>
77+
78+
3179
{% assign tag_filter = page.url | split: '?tag=' | last %}
3280
{% if tag_filter == page.url %}
3381
{% assign tag_filter = nil %}
@@ -41,7 +89,7 @@ title: Blog
4189
{% if filtered_posts.size > 0 %}
4290
<ul class="post-list">
4391
{% for post in filtered_posts %}
44-
<li class="post-item">
92+
<li class="post-item" data-tags="{% assign allposttags = post.categories | concat: post.tags | uniq %}{% for tag in allposttags %}{{ tag | downcase }} {% endfor %}">
4593
<h2>
4694
<a class="post-link" href="{{ post.url | relative_url }}">{{ post.title }}</a>
4795
</h2>
@@ -63,3 +111,51 @@ title: Blog
63111
<p>No posts yet. Check back soon!</p>
64112
{% endif %}
65113
</div>
114+
115+
<script>
116+
// Minimal client-side hashtag filter for GitHub Pages
117+
(function() {
118+
function getTagParam() {
119+
const params = new URLSearchParams(window.location.search);
120+
return params.get('tag') ? params.get('tag').toLowerCase() : null;
121+
}
122+
function filterPostsByTag(tag) {
123+
var posts = document.querySelectorAll('.post-list .post-item');
124+
posts.forEach(function(post) {
125+
const tags = post.getAttribute('data-tags') || '';
126+
if (!tag || tags.includes(tag)) {
127+
post.style.display = '';
128+
} else {
129+
post.style.display = 'none';
130+
}
131+
});
132+
}
133+
function highlightActiveTag(tag) {
134+
var links = document.querySelectorAll('.hashtag-link');
135+
links.forEach(function(link) {
136+
var linkTag = link.textContent.replace(/^#/, '').toLowerCase();
137+
if (tag && linkTag === tag) {
138+
link.classList.add('active');
139+
} else {
140+
link.classList.remove('active');
141+
}
142+
});
143+
}
144+
var tag = getTagParam();
145+
if (tag) {
146+
filterPostsByTag(tag);
147+
highlightActiveTag(tag);
148+
}
149+
})();
150+
</script>
151+
152+
<style>
153+
/* Minimal highlight for active hashtag */
154+
.hashtag-link.active {
155+
background: var(--hashtag-hover-bg, #e0e7ef);
156+
color: var(--hashtag-hover-color, #007acc);
157+
border-color: var(--hashtag-hover-border, #b3c7e6);
158+
font-weight: 600;
159+
}
160+
</style>
161+

0 commit comments

Comments
 (0)