-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost_template.html
More file actions
534 lines (455 loc) · 20.5 KB
/
post_template.html
File metadata and controls
534 lines (455 loc) · 20.5 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
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Site Info -->
<title>{{ post.title }} - {{ name }}</title>
<meta name="description" content="{{ post.content | striptags | truncate(160) }}">
<meta name="author" content="{{ name }}">
<!-- Base URL to fix relative paths -->
<base href="../">
<!-- Open Graph Tags (for social media sharing) -->
<meta property="og:title" content="{{ post.title }}">
<meta property="og:type" content="article">
<meta property="og:url" content="{{ base_url }}/posts/{{ post.slug }}.html">
<meta property="og:image" content="{{ base_url }}/{{ image_path }}">
<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">
<link rel="stylesheet" href="css/post.css">
<!-- Icon & Favicon Libraries -->
<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" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.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">
</head>
<body>
<header class="page-header">
<div class="container">
<div class="header-top flex-responsive">
<div class="header-info">
<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="blog.html">Blog Home</a></li>
</ul>
</nav>
</div>
</div>
</div>
</header>
<div class="page-content">
<div class="container post-layout">
<!-- Left Sidebar for TOC -->
<aside class="post-sidebar-left">
<!-- Table of Contents Section (Dynamically Generated) -->
<section id="toc-section" style="display: none;">
<h2 class="section-heading"
style="text-align: left; margin-bottom: 0.5rem; justify-content: flex-start;">On this page</h2>
<div id="toc-container"></div>
</section>
</aside>
<!-- Center Column: Article ONLY -->
<div class="post-center-column">
<main class="post-content-main" style="padding: 2rem 0 0 0;">
{{ post.detailed_content | safe }}
</main>
</div>
<!-- Right Sidebar with Post Info and Keywords -->
<aside class="post-sidebar-right">
<!-- Part of a series navigation -->
{% if post.next_part_slug or post.previous_part_slug %}
<section class="series-navigation-sidebar">
<h4>This post is part of a series.</h4>
{% if post.previous_part_slug %}
<a href="posts/{{ post.previous_part_slug }}.html" class="series-link">← Read Part {{
post.previous_part_num }}</a>
{% endif %}
{% if post.next_part_slug %}
<a href="posts/{{ post.next_part_slug }}.html" class="series-link">Read Part {{ post.next_part_num
}} →</a>
{% endif %}
</section>
{% endif %}
<!-- Post Information Section -->
<section>
<h2 class="section-heading" style="justify-content: flex-start;">Post Information</h2>
<div class="competency-item-sidebar">
<h3 class="competency-title-sidebar" style="line-height: 1.4;">{{ post.title }}</h3>
<p class="section-label">Published on: {{ post.publish_date }}</p>
{% if post.github_url %}
<a href="{{ post.github_url }}" class="sidebar-button" target="_blank"
rel="noopener noreferrer">
<i class="fab fa-github"></i> View on GitHub
</a>
{% endif %}
</div>
</section>
<!-- Technologies & Keywords Section -->
<section>
<h2 class="section-heading" style="justify-content: flex-start;">Technologies & Keywords</h2>
<div class="tech-stack">
{% set all_tags = post.core_technologies + post.keywords %}
{% set unique_tags = [] %}
{% for tag in all_tags %}
{% if tag not in unique_tags %}
{% set _ = unique_tags.append(tag) %}
{% endif %}
{% endfor %}
{% for tag in unique_tags %}
<span class="tag" style="margin-bottom: 0.2rem;">{{ tag }}</span>
{% endfor %}
</div>
</section>
</aside>
</div> <!-- Close .post-layout grid -->
<!-- Navigation block entirely detached from the sidebars grid -->
<div class="container" style="max-width: 1550px; margin: 0 auto; padding: 0 1rem;">
<nav class="post-navigation" style="width: 100%; box-sizing: border-box;">
<!-- OLDER POST LINK LOGIC -->
{% if post.previous_part_slug %}
<!-- Link back to the previous part dynamically -->
<a href="posts/{{ post.previous_part_slug }}.html" class="nav-link prev-link">
<span class="arrow">←</span>
<span class="nav-text">
<span class="nav-label">Read Part {{ post.previous_part_num }}</span>
{{ post.title.split(' (Part ')[0] }}
</span>
</a>
{% elif post.next_post %}
<!-- Otherwise, link to the chronologically older post (standard behavior) -->
<a href="posts/{{ post.next_post.slug }}.html" class="nav-link prev-link">
<span class="arrow">←</span>
<span class="nav-text">
<span class="nav-label">Older Post</span>
{{ post.next_post.title }}
</span>
</a>
{% else %}
<!-- Empty div to maintain layout if there's no older post -->
<div></div>
{% endif %}
<!-- NEWER POST LINK LOGIC -->
{% if post.next_part_slug %}
<!-- Link forward to the next part dynamically -->
<a href="posts/{{ post.next_part_slug }}.html" class="nav-link next-link">
<span class="nav-text">
<span class="nav-label">Read Part {{ post.next_part_num }}</span>
{{ post.title.split(' (Part ')[0] }}
</span>
<span class="arrow">→</span>
</a>
{% elif post.previous_post %}
<!-- Otherwise, link to the chronologically newer post (standard behavior) -->
<a href="posts/{{ post.previous_post.slug }}.html" class="nav-link next-link">
<span class="nav-text">
<span class="nav-label">Newer Post</span>
{{ post.previous_post.title }}
</span>
<span class="arrow">→</span>
</a>
{% endif %}
</nav>
</div> <!-- Close navigation container -->
</div>
<footer class="page-footer">
<div class="container">
<p>© {{ current_year }} {{ name }}. All rights reserved.</p>
</div>
</footer>
<!-- Prism JS for Code Highlighting -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-core.min.js"></script>
<!-- ADD THIS LINE TO LOAD THE PYTHON LANGUAGE -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-python.min.js"></script>
<!-- ===== 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>
<style>
/* Modern 3-Column Post Layout Grid */
.post-layout {
display: flex !important;
flex-direction: column !important;
gap: 2rem;
max-width: 1550px;
margin: 0 auto;
}
/* Adjustments for tablets and large desktop screens */
@media (min-width: 48rem) {
.post-layout {
display: grid !important;
grid-template-columns: 1fr 300px !important;
align-items: start;
}
.post-center-column {
grid-row: 1 / span 2;
grid-column: 1;
}
.post-sidebar-left {
grid-row: 2;
grid-column: 2;
margin-top: 2rem;
}
.post-sidebar-right {
grid-row: 1;
grid-column: 2;
}
}
@media (min-width: 75rem) {
.post-layout {
grid-template-columns: minmax(300px, 1fr) minmax(600px, 2.2fr) minmax(320px, 1.2fr) !important;
gap: 4rem;
}
.post-sidebar-left {
grid-row: 1;
grid-column: 1;
margin-top: 0;
}
.post-center-column {
grid-row: 1;
grid-column: 2;
}
.post-sidebar-right {
grid-row: 1;
grid-column: 3;
}
}
/* Sticky Sidebars */
.post-sidebar-left,
.post-sidebar-right {
position: sticky;
top: 2rem;
z-index: 5;
align-self: start;
max-height: calc(100vh - 4rem);
overflow-y: auto;
border-left: 1px solid transparent !important;
}
.post-sidebar-right {
border-left: 1px solid var(--border-color) !important;
padding-left: 1.5rem;
}
/* Optional custom scrollbar for sidebars */
.post-sidebar-left::-webkit-scrollbar,
.post-sidebar-right::-webkit-scrollbar {
width: 5px;
}
.post-sidebar-left::-webkit-scrollbar-track,
.post-sidebar-right::-webkit-scrollbar-track {
background: rgba(0, 0, 0, 0.05);
}
.post-sidebar-left::-webkit-scrollbar-thumb,
.post-sidebar-right::-webkit-scrollbar-thumb {
background: rgba(0, 0, 0, 0.2);
border-radius: 10px;
}
html[data-theme='dark'] .post-sidebar-left::-webkit-scrollbar-track,
html[data-theme='dark'] .post-sidebar-right::-webkit-scrollbar-track {
background: rgba(255, 255, 255, 0.05);
}
html[data-theme='dark'] .post-sidebar-left::-webkit-scrollbar-thumb,
html[data-theme='dark'] .post-sidebar-right::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.2);
}
/* TOC Styles */
#toc-container {
margin-top: 0.5rem;
font-size: 0.9rem;
}
.toc-list {
list-style: none;
padding-left: 0;
margin-bottom: 0;
display: flex;
flex-direction: column;
gap: 0.25rem;
}
.toc-link {
display: block;
color: var(--text-color);
text-decoration: none;
line-height: 1.4;
padding: 0.25rem 0 0.25rem 0.5rem;
border-left: 2px solid transparent;
transition: all 0.2s ease-in-out;
opacity: 0.8;
word-break: break-word;
/* To prevent long headings from spilling over */
}
.toc-link:hover {
color: var(--link-color, #0077cc);
opacity: 1;
}
.toc-link.active {
font-weight: 600;
color: var(--link-color, #0077cc);
border-left: 2px solid var(--link-color, #0077cc);
background-color: rgba(0, 119, 204, 0.05);
opacity: 1;
}
/* Highlight styling for Images in TOC */
.toc-link-image {
font-style: italic;
font-size: 0.85em;
}
.toc-link i {
margin-right: 0.4rem;
color: gray;
}
</style>
<script>
document.addEventListener("DOMContentLoaded", () => {
const mainContent = document.querySelector(".post-content-main");
const tocSection = document.getElementById("toc-section");
const tocContainer = document.getElementById("toc-container");
if (!mainContent || !tocSection || !tocContainer) return;
// Capture all headings and images within the post content
const elements = Array.from(mainContent.querySelectorAll("h1, h2, h3, h4, h5, h6, img"));
if (elements.length === 0) return;
tocSection.style.display = "block";
const tocList = document.createElement("ul");
tocList.className = "toc-list";
const links = new Map();
let activeLink = null;
let imgCounter = 1;
elements.forEach((el) => {
// Ensure target has an ID
if (!el.id) {
if (el.tagName === "IMG") {
el.id = "content-img-" + imgCounter++;
} else {
// Create URL-friendly slug from heading text
let slug = el.textContent.trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/(^-|-$)/g, '');
if (!slug) slug = "section-" + imgCounter++;
// Ensure unique ID
let origSlug = slug;
let counter = 1;
while (document.getElementById(slug)) {
slug = origSlug + "-" + counter++;
}
el.id = slug;
}
}
const li = document.createElement("li");
const a = document.createElement("a");
a.href = "#" + el.id;
a.className = "toc-link";
a.addEventListener('click', (e) => {
e.preventDefault();
history.pushState(null, null, '#' + el.id);
el.scrollIntoView({ behavior: 'smooth' });
});
if (el.tagName === "IMG") {
const altText = el.alt ? el.alt : "Image";
a.innerHTML = `<i class="fa-solid fa-image"></i> ${altText}`;
a.classList.add("toc-link-image");
a.style.marginLeft = "1rem"; // Indent images slightly
} else {
a.textContent = el.textContent;
// Indent based on heading level
const level = parseInt(el.tagName.charAt(1));
if (level > 2) {
a.style.marginLeft = `${(level - 2) * 1}rem`;
}
}
li.appendChild(a);
tocList.appendChild(li);
links.set(el, a);
});
tocContainer.appendChild(tocList);
// Scrollspy logic
function updateScrollSpy() {
let currentActive = null;
let maxNegativeTop = -Infinity;
let elementWithMaxNegativeTop = null;
const OFFSET = 150; // pixels from top of viewport to consider "active"
for (const el of elements) {
const rect = el.getBoundingClientRect();
if (rect.top <= OFFSET) {
if (rect.top > maxNegativeTop) {
maxNegativeTop = rect.top;
elementWithMaxNegativeTop = el;
}
}
}
currentActive = elementWithMaxNegativeTop;
// Check if user scrolled to the absolute bottom of the page
const isBottom = Math.ceil(window.innerHeight + window.scrollY) >= document.documentElement.scrollHeight - 20;
// Highlight the very last element naturally if we're at the bottom
if (isBottom && elements.length > 0) {
currentActive = elements[elements.length - 1];
} else if (!currentActive && elements.length > 0) {
// Fallback: highlight the first item if none are past the offset and not at bottom
currentActive = elements[0];
}
if (currentActive) {
const targetLink = links.get(currentActive);
if (targetLink && targetLink !== activeLink) {
if (activeLink) activeLink.classList.remove("active");
targetLink.classList.add("active");
activeLink = targetLink;
// Scroll TOC container if newly active item is out of view
const linkRect = targetLink.getBoundingClientRect();
const tocRect = tocSection.getBoundingClientRect();
if (linkRect.bottom > tocRect.bottom || linkRect.top < tocRect.top) {
targetLink.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}
}
}
}
window.addEventListener('scroll', updateScrollSpy, { passive: true });
// Initial call
updateScrollSpy();
});
</script>
</body>
</html>