-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblog_template.html
More file actions
459 lines (390 loc) · 18.4 KB
/
blog_template.html
File metadata and controls
459 lines (390 loc) · 18.4 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Site Info -->
<title>{{ name }} - Blog</title>
<meta name="description" content="{{ name }} - {{ summary }}">
<meta name="author" content="{{ name }}">
<!-- Open Graph Tags: The title of the page for social media sharing. It can match the title tag or be more descriptive. -->
<meta property="og:title" content="{{ name }}">
<!-- Open Graph Tags: Typically set to "website" for static sites or "article" for content-heavy pages. -->
<meta property="og:type" content="website">
<!-- Open Graph Tags: The URL of the page, used to ensure link previews resolve to the correct page. -->
<!-- base_url -->
<meta property="og:url" content="{{ base_url }}/blog.html">
<!-- Open Graph Tags: URL of an image that represents the page. Useful for link previews. -->
<!-- base_url -->
<meta property="og:image" content="{{ base_url }}/{{ image_path }}">
<!-- Open Graph Tags: Provides an alternative text for the image to improve accessibility. -->
<meta property="og:image:alt" content="{{ name }} Profile Image">
<!-- Preconnect for Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- Custom Font -->
<link
href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap"
rel="stylesheet">
<!-- Stylesheet -->
<link rel="stylesheet" href="css/modern_normalize.css" />
<link rel="stylesheet" href="css/html5bp.css">
<link rel="stylesheet" href="css/main.css">
<!-- <link rel="stylesheet" href="css/resume.css"> -->
<!-- Set a theme color that matches your website's primary color -->
<meta name="theme-color" content="#fafafa">
<!-- Favicon for all browsers -->
<link rel="icon" href="/favicon.ico" sizes="any">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<!-- Apple touch icon for iOS devices -->
<link rel="apple-touch-icon" sizes="180x180" href="/icon.png">
<!-- Web app manifest for Progressive Web Apps -->
<link rel="manifest" href="/site.webmanifest">
<!-- Add an icon library -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css"
integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<!-- Content Security Policy: Uncomment to enhance security by restricting where content can be loaded from (useful for preventing certain attacks like XSS). Update if adding external sources (e.g., Google Fonts, Bootstrap CDN, analytics, etc). -->
<!-- <meta http-equiv="Content-Security-Policy" content=" default-src 'self'; script-src 'self' code.jquery.com; style-src 'self' fonts.googleapis.com; font-src fonts.gstatic.com; img-src 'self' images.examplecdn.com; "> -->
</head>
<body>
<header class="page-header">
<div class="container">
<div class="header-top flex-responsive">
<div class="header-info">
<!-- name -->
<h1>{{ name }}'s Blog</h1>
<nav>
<ul class="inline-list flex-responsive">
<li><a href="index.html">Home</a></li>
<li><a href="resume.html">Resume</a></li>
<li><a href="projects.html">Projects</a></li>
<li><a href="tech-stack.html">Tech Stack</a></li>
<li><a href="contact.html">Contact</a></li>
</ul>
</nav>
</div>
</div>
</div>
</header>
<div class="page-content">
<div class="container">
<main>
<section>
<div class="blog-heading-row">
<h2 class="section-heading">
<span style="display: inline-flex; align-items: baseline; gap: 0.5rem;">
Recent Posts
<span
style="font-size: 0.65em; font-weight: 500; opacity: 0.6; text-transform: uppercase; font-style: italic; letter-spacing: 0.5px;">Total
Posts: {{ blogs | length }}</span>
</span>
</h2>
<!-- Mobile filter toggle button (hidden on desktop) -->
<button id="mobile-filter-toggle" class="mobile-filter-toggle"
aria-label="Filter by technology">
<i class="fas fa-filter"></i>
<span class="mobile-filter-label">Filter</span>
</button>
</div>
<!-- Mobile filter dropdown (hidden by default, shown on toggle) -->
<div id="mobile-filter-panel" class="mobile-filter-panel">
<div id="mobile-tag-filter-container" class="mobile-tag-container">
<button class="tag filter-tag active" data-tag="all">Show All</button>
{% for tag in tags %}
<button class="tag filter-tag" data-tag="{{ tag | lower }}">{{ tag }}</button>
{% endfor %}
</div>
</div>
<!-- blogs -->
<div id="blog-posts-container">
{% for post in blogs %}
<article class="blog-post" data-tags="{{ post.core_technologies | join(',') | lower }}">
<h3 class="post-meta">
<a href="posts/{{ post.slug }}.html">{{ post.title }}</a>
</h3>
<p class="section-label">Published on: {{ post.publish_date }}</p>
{% if post.content %}
<p>{{ post.content | markdown_to_html | safe }}</p>
{% endif %}
<div class="tech-stack">
{% if post.technologies %}
{% for tech in post.core_technologies %}
<span class="tag">{{ tech }}</span>
{% endfor %}
{% for keyword in post.keywords %}
<span class="tag">{{ keyword }}</span>
{% endfor %}
{% endif %}
</div>
</article>
{% endfor %}
</div>
<div class="load-more-wrapper" style="text-align: center; margin-top: 2rem;">
<button id="load-more-btn" class="load-more-btn">Load More Posts</button>
</div>
</section>
</main>
<!-- Sidebar Section -->
<aside>
<!-- PASTE THE FILTER SECTION YOU CUT EARLIER RIGHT HERE -->
<section>
<h2 class="section-heading">Filter by Technology</h2>
<div id="tag-filter-container" class="tech-stack">
<button class="tag filter-tag active" data-tag="all">Show All</button>
{% for tag in tags %}
<button class="tag filter-tag" data-tag="{{ tag | lower }}">{{ tag }}</button>
{% endfor %}
</div>
</section>
</aside>
</div>
</div>
<footer class="page-footer">
<div class="container">
<p>© {{ current_year }} {{ name }}. All rights reserved.</p>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const tagContainer = document.getElementById('tag-filter-container');
const mobileTagContainer = document.getElementById('mobile-tag-filter-container');
const blogPosts = Array.from(document.querySelectorAll('.blog-post'));
const loadMoreBtn = document.getElementById('load-more-btn');
const mobileFilterToggle = document.getElementById('mobile-filter-toggle');
const mobileFilterPanel = document.getElementById('mobile-filter-panel');
let currentMax = 5;
const POSTS_PER_PAGE = 5;
let currentFilter = 'all';
function updatePostsDisplay() {
let visibleCount = 0;
// Filter posts
const matchingPosts = blogPosts.filter(post => {
const postTags = post.getAttribute('data-tags');
return currentFilter === 'all' || postTags.includes(currentFilter);
});
// Hide all posts first
blogPosts.forEach(post => { post.style.display = 'none'; });
// Show up to currentMax matching posts
for (let i = 0; i < matchingPosts.length; i++) {
if (i < currentMax) {
matchingPosts[i].style.display = 'block';
visibleCount++;
}
}
// Update Load More button visibility
if (visibleCount >= matchingPosts.length) {
loadMoreBtn.style.display = 'none';
} else {
loadMoreBtn.style.display = 'inline-block';
}
}
// Sync active state across both filter containers
function syncFilterState(clickedTag, sourceContainer) {
const allContainers = [tagContainer, mobileTagContainer].filter(Boolean);
const selectedTag = clickedTag.getAttribute('data-tag').toLowerCase();
allContainers.forEach(container => {
container.querySelectorAll('.filter-tag').forEach(btn => {
btn.classList.remove('active');
if (btn.getAttribute('data-tag').toLowerCase() === selectedTag) {
btn.classList.add('active');
}
});
});
currentFilter = selectedTag;
currentMax = POSTS_PER_PAGE;
updatePostsDisplay();
}
// Desktop sidebar filter
if (tagContainer) {
tagContainer.addEventListener('click', function (e) {
if (e.target.matches('.filter-tag')) {
syncFilterState(e.target, tagContainer);
}
});
}
// Mobile filter dropdown
if (mobileTagContainer) {
mobileTagContainer.addEventListener('click', function (e) {
if (e.target.matches('.filter-tag')) {
syncFilterState(e.target, mobileTagContainer);
}
});
}
// Mobile filter toggle button
if (mobileFilterToggle && mobileFilterPanel) {
mobileFilterToggle.addEventListener('click', function () {
const isOpen = mobileFilterPanel.classList.toggle('open');
mobileFilterToggle.classList.toggle('active', isOpen);
});
}
if (loadMoreBtn) {
loadMoreBtn.addEventListener('click', function () {
currentMax += POSTS_PER_PAGE;
updatePostsDisplay();
});
}
// Initial display update
updatePostsDisplay();
});
</script>
<style>
/* ===== Filter Tag Base Styles ===== */
.filter-tag {
cursor: pointer;
border: 1px solid transparent;
}
.filter-tag.active {
border-color: var(--link-color, #0077cc);
background-color: #cceeff;
color: #000;
}
/* Desktop sidebar filter layout */
#tag-filter-container {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
#tag-filter-container .filter-tag {
width: 100%;
text-align: left;
margin-right: 0;
}
/* Load more button styles */
.load-more-btn {
padding: 10px 24px;
border: 2px solid var(--link-color, #0077cc);
border-radius: 6px;
background-color: transparent;
color: var(--link-color, #0077cc);
font-weight: bold;
font-size: 1rem;
cursor: pointer;
transition: all 0.2s ease-in-out;
}
.load-more-btn:hover {
background-color: var(--link-color, #0077cc);
color: #fff;
}
/* ===== Blog Heading Row ===== */
.blog-heading-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
}
.blog-heading-row .section-heading {
flex: 1;
margin-bottom: 0;
}
/* ===== Mobile Filter Toggle Button ===== */
.mobile-filter-toggle {
display: none;
/* Hidden by default on desktop */
}
/* ===== Mobile Filter Panel ===== */
.mobile-filter-panel {
display: none;
/* Hidden by default */
}
/* ===== Mobile / Tablet: show filter button, hide sidebar ===== */
@media (max-width: 48rem) {
/* Hide the desktop sidebar completely on mobile */
aside {
display: none !important;
}
/* Show the mobile filter toggle button */
.mobile-filter-toggle {
display: inline-flex;
align-items: center;
gap: 0.4rem;
padding: 8px 14px;
border: 1px solid var(--border-color);
border-radius: 6px;
background-color: var(--card-bg-color);
color: var(--text-color);
font-size: 0.9rem;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
flex-shrink: 0;
font-family: inherit;
}
.mobile-filter-toggle i {
font-size: 0.85rem;
color: var(--link-color);
}
.mobile-filter-toggle:hover,
.mobile-filter-toggle.active {
border-color: var(--link-color);
color: var(--link-color);
}
/* Mobile filter panel (dropdown) */
.mobile-filter-panel {
display: none;
/* Still hidden until .open is added */
}
.mobile-filter-panel.open {
display: block;
margin-bottom: 1.5rem;
padding: 1rem;
background-color: var(--card-bg-color);
border: 1px solid var(--border-color);
border-radius: 8px;
animation: filterSlideDown 0.25s ease-out;
}
@keyframes filterSlideDown {
from {
opacity: 0;
transform: translateY(-8px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* Mobile tag container: horizontal wrap layout */
.mobile-tag-container {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.mobile-tag-container .filter-tag {
font-size: 0.85rem;
padding: 4px 10px;
}
}
</style>
</footer>
<!-- ===== Style Switcher Start ===== -->
<div class="theme-toggle-container">
<div id="theme-toggle-icon" class="theme-icon">
<i class="fas"></i>
</div>
</div>
<!-- ===== Style Switcher End ===== -->
<!-- ===== Search Feature Start ===== -->
<button id="search-fab" class="search-fab" aria-label="Search blog posts">
<i class="fas fa-magnifying-glass"></i>
</button>
<div id="search-overlay" class="search-overlay">
<div class="search-modal">
<div class="search-header">
<i class="fas fa-magnifying-glass"></i>
<input type="text" id="search-input" placeholder="Search blog posts…" autocomplete="off">
<span class="search-kbd">⌘K</span>
<button id="search-clear-btn" class="search-action-btn" aria-label="Clear search"
style="display:none;"><i class="fas fa-delete-left"></i></button>
<button id="search-close-btn" class="search-action-btn" aria-label="Close search"><i
class="fas fa-xmark"></i></button>
</div>
<div id="search-results" class="search-results">
<p class="search-hint">Type at least 2 characters to search…</p>
</div>
</div>
</div>
<!-- ===== Search Feature End ===== -->
<script src="js/search-index.js"></script>
<script src="js/search.js"></script>
<script src="js/app.js"></script>
</body>
</html>