-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
423 lines (376 loc) · 28.4 KB
/
Copy pathindex.html
File metadata and controls
423 lines (376 loc) · 28.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tomo's log</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Newsreader:ital,wght@0,400;0,500;1,400&display=swap" rel="stylesheet">
<style>
/* Sans-serif for body copy, serif for headings - editorial, minimal look */
body {
font-family: 'Inter', sans-serif;
scroll-behavior: smooth; /* Smooth scrolling for anchor links */
}
.font-display {
font-family: 'Newsreader', serif;
}
/* A simple fade-in animation for page content */
.page-content {
animation: fadeIn 0.5s ease-in-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
/* Basic styling for rendered Markdown content */
.prose h1, .prose h2, .prose h3 {
font-family: 'Newsreader', serif;
font-weight: 500;
margin-bottom: 0.5em;
margin-top: 1em;
}
.prose h1 { font-size: 2.25rem; }
.prose h2 { font-size: 1.875rem; }
.prose h3 { font-size: 1.5rem; }
.prose p {
margin-bottom: 1em;
line-height: 1.7;
}
.prose a {
color: #1c1917; /* stone-900 */
text-decoration: underline;
text-decoration-color: #d6d3d1; /* stone-300 */
text-underline-offset: 4px;
}
.prose ul {
list-style-type: disc;
padding-left: 1.5em;
margin-bottom: 1em;
}
.prose pre {
background-color: #f5f5f4; /* stone-100 */
padding: 1em;
border-radius: 0.25rem;
overflow-x: auto;
}
.prose code {
font-family: monospace;
}
</style>
</head>
<body class="bg-[#faf9f6] text-stone-800">
<header class="bg-[#faf9f6]/90 backdrop-blur-md sticky top-0 z-50 border-b border-stone-200">
<nav class="max-w-3xl mx-auto px-6 py-5 flex justify-between items-center">
<a href="#home" class="nav-link font-display text-xl text-stone-900">Tomo's log</a>
<div class="hidden md:flex space-x-8">
<a href="#home" class="nav-link text-xs uppercase tracking-widest text-stone-500 hover:text-stone-900 transition-colors">Home</a>
<a href="#blog" class="nav-link text-xs uppercase tracking-widest text-stone-500 hover:text-stone-900 transition-colors">Blog</a>
<a href="#publications" class="nav-link text-xs uppercase tracking-widest text-stone-500 hover:text-stone-900 transition-colors">Publications</a>
</div>
<button id="menu-btn" class="md:hidden block text-stone-800 focus:outline-none">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16m-7 6h7"></path>
</svg>
</button>
</nav>
<div id="mobile-menu" class="hidden md:hidden border-t border-stone-200">
<a href="#home" class="mobile-nav-link block py-3 px-4 text-xs uppercase tracking-widest text-stone-600 hover:bg-stone-100">Home</a>
<a href="#blog" class="mobile-nav-link block py-3 px-4 text-xs uppercase tracking-widest text-stone-600 hover:bg-stone-100">Blog</a>
<a href="#publications" class="mobile-nav-link block py-3 px-4 text-xs uppercase tracking-widest text-stone-600 hover:bg-stone-100">Publications</a>
</div>
</header>
<div class="max-w-3xl mx-auto px-6 py-8 sm:py-12">
<main id="home" class="page-content">
<h1 class="font-display text-4xl sm:text-5xl text-stone-900 mb-6">Hello, visitor! 🖖</h1>
<div>
<img src="img/profile_pic.jpg" alt="Tomaso" class="w-28 h-28 sm:w-40 sm:h-40 object-cover rounded-full border border-stone-200 mx-auto mb-4 sm:float-left sm:mx-0 sm:mr-6 sm:mb-2">
<p class="text-lg text-stone-600 leading-relaxed">
I am Tomo, aka Tomaso Trinci, a Data Scientist at <a href="https://www.verizonconnect.com/" class="underline decoration-stone-300 hover:decoration-stone-900 text-stone-900">Verizon Connect</a> in Florence. My journey started at <a href="https://www.reply.com/target-reply/en" class="underline decoration-stone-300 hover:decoration-stone-900 text-stone-900">Target Reply</a> in Milan before I headed back here to earn my Ph.D. in Machine Learning with the <a href="https://webgol.dinfo.unifi.it/" class="underline decoration-stone-300 hover:decoration-stone-900 text-stone-900">Global Optimization Laboratory</a>.<br><br>
With a background blending Math and Computer Engineering, I am currently focused on computer vision, intelligent vehicle applications, and multimodal models. In the past, I've also spent time diving into continual learning and sustainable AI.<br><br>
When I'm not training models, I’m training my palate; I completed the first level of the sommelier course at <a href="https://www.fisar.org/" class="underline decoration-stone-300 hover:decoration-stone-900 text-stone-900">FISAR</a>, mostly because wine tasting is a task that machine learning (still) hasn't managed to solve. I'm also an avid comics reader, from manga to graphic novels, and my favorite author is <a href="https://it.wikipedia.org/wiki/Zerocalcare" class="underline decoration-stone-300 hover:decoration-stone-900 text-stone-900">Zerocalcare</a>.<br><br>
P.S. I know next to nothing about front-end. This page was realized by simply vibing with Gemini and Claude 🤖
</p>
</div>
<div class="clear-left mt-6 flex flex-wrap gap-x-4 gap-y-2">
<a href="mailto:tomaso.trinci90@gmail.com" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">Email</a>
<a href="https://github.com/CodingTomo" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">GitHub</a>
<a href="https://it.linkedin.com/in/tomasotrinci" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">LinkedIn</a>
<a href="https://bsky.app/profile/tomo-90.bsky.social" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">Bluesky</a>
<a href="https://scholar.google.com/citations?user=kfN-d6IAAAAJ&hl=it" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">Google Scholar</a>
</div>
</main>
<main id="blog" class="page-content hidden">
<div id="blog-list-container">
<h1 class="font-display text-4xl sm:text-5xl text-stone-900 mb-10">Blog</h1>
<div id="blog-list" class="divide-y divide-stone-200">
</div>
</div>
<div id="blog-post-container" class="hidden">
<button id="back-to-blog" class="mb-8 text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">← Back to Blog List</button>
<div id="blog-post-content" class="prose max-w-none"></div>
</div>
</main>
<main id="publications" class="page-content hidden">
<h1 class="font-display text-4xl sm:text-5xl text-stone-900 mb-10">Publications</h1>
<div>
<div class="py-8 border-t border-stone-200 first:border-t-0 first:pt-0 flex flex-col sm:flex-row items-center sm:items-start text-center sm:text-left gap-6">
<img src="img/flara.png" alt="Publication Image" class="w-20 h-20 object-cover flex-shrink-0 border border-stone-200 bg-white">
<div>
<h3 class="font-display text-xl text-stone-900">FLaRA: Predicting Future Latent Representations for Accident Anticipation</h3>
<p class="mt-1 text-stone-600 text-sm"> L. Caselli, <strong>T. Trinci</strong>, T. Bianconcini, S. Magistri, L. Taccari, F. Sambo, A.D. Bagdanov (2026).</p>
<p class="mt-1 text-stone-500 text-sm italic">Preprint, Accepted at International Conference on Intelligent Transportation Systems (ITSC)</p>
<div class="mt-3 space-x-4 text-sm">
<a href="https://arxiv.org/pdf/2606.14380" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[PDF]</a>
</div>
</div>
</div>
<div class="py-8 border-t border-stone-200 first:border-t-0 first:pt-0 flex flex-col sm:flex-row items-center sm:items-start text-center sm:text-left gap-6">
<img src="img/vzcrash.png" alt="Publication Image" class="w-20 h-20 object-cover flex-shrink-0 border border-stone-200 bg-white">
<div>
<h3 class="font-display text-xl text-stone-900">VZCrash: A Large-Scale IMU Dataset of Ego-Vehicle Crashes</h3>
<p class="mt-1 text-stone-600 text-sm"> T. Bianconcini, H. P. Monteagudo, A. Pjetri, <strong>T. Trinci</strong>, L. Taccari (2026).</p>
<p class="mt-1 text-stone-500 text-sm italic">Preprint, Accepted at International Conference on Intelligent Transportation Systems (ITSC)</p>
<div class="mt-3 space-x-4 text-sm">
<a href="https://arxiv.org/pdf/2606.06074" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[PDF]</a>
<a href="https://huggingface.co/datasets/vzc-research-chapter/VZCrash" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[Dataset]</a>
</div>
</div>
</div>
<div class="py-8 border-t border-stone-200 first:border-t-0 first:pt-0 flex flex-col sm:flex-row items-center sm:items-start text-center sm:text-left gap-6">
<img src="img/mllm.png" alt="Publication Image" class="w-20 h-20 object-cover flex-shrink-0 border border-stone-200 bg-white">
<div>
<h3 class="font-display text-xl text-stone-900">Enhancing Multimodal Large Language Models for Safety-Critical Driving Video Analysis</h3>
<p class="mt-1 text-stone-600 text-sm"> <strong>T. Trinci</strong>, H. P. Monteagudo, L. Taccari (2026).</p>
<p class="mt-1 text-stone-500 text-sm italic">Preprint, Accepted at International Conference on Intelligent Transportation Systems (ITSC)</p>
<div class="mt-3 space-x-4 text-sm">
<a href="https://arxiv.org/pdf/2605.22185" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[PDF]</a>
</div>
</div>
</div>
<div class="py-8 border-t border-stone-200 first:border-t-0 first:pt-0 flex flex-col sm:flex-row items-center sm:items-start text-center sm:text-left gap-6">
<img src="img/color_is_not.png" alt="Publication Image" class="w-20 h-20 object-cover flex-shrink-0 border border-stone-200 bg-white">
<div>
<h3 class="font-display text-xl text-stone-900">Color is not enough: dataset and method for identifying relevant traffic lights in driving scenes</h3>
<p class="mt-1 text-stone-600 text-sm"> <strong>T. Trinci</strong>, S. Magistri, T. Bianconcini, L. Sarti, L. Taccari, F. Sambo (2025).</p>
<p class="mt-1 text-stone-500 text-sm italic">IEEE Transactions on Intelligent Transportation Systems, pp. 1116-1125</p>
<div class="mt-3 space-x-4 text-sm">
<a href="https://ieeexplore.ieee.org/document/11241141/" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[PDF]</a>
<a href="https://huggingface.co/datasets/vzc-research-chapter/vzc-traffic-light-dataset" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[Dataset]</a>
</div>
</div>
</div>
<div class="py-8 border-t border-stone-200 first:border-t-0 first:pt-0 flex flex-col sm:flex-row items-center sm:items-start text-center sm:text-left gap-6">
<img src="img/efc++.png" alt="Publication Image" class="w-20 h-20 object-cover flex-shrink-0 border border-stone-200 bg-white">
<div>
<h3 class="font-display text-xl text-stone-900">EFC++: Elastic Feature Consolidation with Prototype Re-balancing for Cold Start Exemplar-free Incremental Learning</h3>
<p class="mt-1 text-stone-600 text-sm">S. Magistri, <strong>T. Trinci</strong>, A. Soutif-Cormerais, J. van de Weijer, A.D. Bagdanov (2025).</p>
<p class="mt-1 text-stone-500 text-sm italic">[Under Review since July 2024]</p>
<div class="mt-3 space-x-4 text-sm">
<a href="https://arxiv.org/pdf/2503.10439" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[PDF]</a>
<a href="https://github.com/simomagi/elastic_feature_consolidation" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[Code]</a>
</div>
</div>
</div>
<div class="py-8 border-t border-stone-200 first:border-t-0 first:pt-0 flex flex-col sm:flex-row items-center sm:items-start text-center sm:text-left gap-6">
<img src="img/green_ai.png" alt="Publication Image" class="w-20 h-20 object-cover flex-shrink-0 border border-stone-200 bg-white">
<div>
<h3 class="font-display text-xl text-stone-900">How green is continual learning, really? Analyzing the energy consumption in continual training of vision foundation models</h3>
<p class="mt-1 text-stone-600 text-sm"><strong>T. Trinci</strong>, S. Magistri, R. Verdecchia, A.D. Bagdanov. (2024).</p>
<p class="mt-1 text-stone-500 text-sm italic">Computer Vision – ECCV 2024 Workshops, Part XXII, pp. 300-317.</p>
<div class="mt-3 space-x-4 text-sm">
<a href="https://arxiv.org/pdf/2409.18664" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[PDF]</a>
<a href="https://github.com/CodingTomo/how-green-continual-learning" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[Code]</a>
</div>
</div>
</div>
<div class="py-8 border-t border-stone-200 first:border-t-0 first:pt-0 flex flex-col sm:flex-row items-center sm:items-start text-center sm:text-left gap-6">
<img src="img/efc.png" alt="Publication Image" class="w-20 h-20 object-cover flex-shrink-0 border border-stone-200 bg-white">
<div>
<h3 class="font-display text-xl text-stone-900">Elastic feature consolidation for cold start exemplar-free incremental learning</h3>
<p class="mt-1 text-stone-600 text-sm">S. Magistri, <strong>T. Trinci</strong>, A. Soutif-Cormerais, J. van de Weijer, A.D. Bagdanov (2024).</p>
<p class="mt-1 text-stone-500 text-sm italic">The Twelfth International Conference on Learning Representations (ICLR).</p>
<div class="mt-3 space-x-4 text-sm">
<a href="https://openreview.net/forum?id=7D9X2cFnt1" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[PDF]</a>
<a href="https://github.com/simomagi/elastic_feature_consolidation" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[Code]</a>
</div>
</div>
</div>
<div class="py-8 border-t border-stone-200 first:border-t-0 first:pt-0 flex flex-col sm:flex-row items-center sm:items-start text-center sm:text-left gap-6">
<img src="img/eff_tl.png" alt="Publication Image" class="w-20 h-20 object-cover flex-shrink-0 border border-stone-200 bg-white">
<div>
<h3 class="font-display text-xl text-stone-900">Cross-Model Temporal Cooperation Via Saliency Maps for Efficient Recognition and Classification of Relevant Traffic Lights</h3>
<p class="mt-1 text-stone-600 text-sm"><strong>T. Trinci</strong>, T. Bianconcini, L. Sarti, L. Taccari, F. Sambo. (2023).</p>
<p class="mt-1 text-stone-500 text-sm italic">International Conference on Intelligent Transportation Systems (ITSC), pp. 2758-2763.</p>
<div class="mt-3 space-x-4 text-sm">
<a href="https://ieeexplore.ieee.org/abstract/document/10421938" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[PDF]</a>
<a href="https://github.com/CodingTomo/traffic-light-relevance-annotation" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[Code]</a>
</div>
</div>
</div>
<div class="py-8 border-t border-stone-200 first:border-t-0 first:pt-0 flex flex-col sm:flex-row items-center sm:items-start text-center sm:text-left gap-6">
<img src="img/q8.svg.png" alt="Publication Image" class="w-20 h-20 object-cover flex-shrink-0 border border-stone-200 bg-white">
<div>
<h3 class="font-display text-xl text-stone-900">Zeros of slice functions and polynomials over dual quaternions</h3>
<p class="mt-1 text-stone-600 text-sm">G. Gentili, C. Stoppato, <strong>T. Trinci</strong> (2021).</p>
<p class="mt-1 text-stone-500 text-sm italic">Transactions of the American Mathematical Society, pp. 5509-5544.</p>
<div class="mt-3 space-x-4 text-sm">
<a href="https://arxiv.org/pdf/1907.13154" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[PDF]</a>
</div>
</div>
</div>
</div>
<h1 class="font-display text-4xl sm:text-5xl text-stone-900 mb-10 mt-20">Patents</h1>
<div>
<div class="py-8 border-t border-stone-200 first:border-t-0 first:pt-0 flex flex-col sm:flex-row items-center sm:items-start text-center sm:text-left gap-6">
<img src="img/patent.png" alt="Publication Image" class="w-20 h-20 object-cover flex-shrink-0 border border-stone-200 bg-white">
<div>
<h3 class="font-display text-xl text-stone-900">Systems and methods for detecting traffic light violations</h3>
<p class="mt-1 text-stone-600 text-sm"><strong>T. Trinci</strong>, T. Bianconcini, L. Sarti, L. Taccari, F. Sambo (2026).</p>
<p class="mt-1 text-stone-500 text-sm italic">US Patent App. 18/907,984.</p>
<div class="mt-3 space-x-4 text-sm">
<a href="https://patents.google.com/patent/US20260100055A1/en" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[PDF]</a>
</div>
</div>
</div>
<div class="py-8 border-t border-stone-200 first:border-t-0 first:pt-0 flex flex-col sm:flex-row items-center sm:items-start text-center sm:text-left gap-6">
<img src="img/patent.png" alt="Publication Image" class="w-20 h-20 object-cover flex-shrink-0 border border-stone-200 bg-white">
<div>
<h3 class="font-display text-xl text-stone-900">Systems and methods for reducing power consumption of executing learning models in vehicle systems</h3>
<p class="mt-1 text-stone-600 text-sm"><strong>T. Trinci</strong>, T. Bianconcini, L. Taccari, F. Sambo, L. Sarti, S. Magistri (2026).</p>
<p class="mt-1 text-stone-500 text-sm italic">US Patent 12,518,522.</p>
<div class="mt-3 space-x-4 text-sm">
<a href="https://patents.google.com/patent/US12518522B2/en" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900">[PDF]</a>
</div>
</div>
</div>
</div>
</main>
</div>
<footer class="border-t border-stone-200 mt-8 sm:mt-12">
<div class="max-w-3xl mx-auto px-6 py-6 text-center text-stone-500 text-xs uppercase tracking-widest">© 2025 Tomaso Trinci</div>
</footer>
<script>
document.addEventListener('DOMContentLoaded', () => {
const pages = document.querySelectorAll('.page-content');
const navLinks = document.querySelectorAll('.nav-link');
const mobileNavLinks = document.querySelectorAll('.mobile-nav-link');
const menuBtn = document.getElementById('menu-btn');
const mobileMenu = document.getElementById('mobile-menu');
const blogListContainer = document.getElementById('blog-list-container');
const blogPostContainer = document.getElementById('blog-post-container');
const blogList = document.getElementById('blog-list');
const blogPostContent = document.getElementById('blog-post-content');
const backToBlogBtn = document.getElementById('back-to-blog');
// --- Mobile Menu Toggle ---
menuBtn.addEventListener('click', () => {
mobileMenu.classList.toggle('hidden');
});
// Close mobile menu when a link is clicked
function closeMobileMenu() {
mobileMenu.classList.add('hidden');
}
mobileNavLinks.forEach(link => link.addEventListener('click', closeMobileMenu));
// =================================================================
// HOW TO ADD A NEW BLOG POST:
// 1. Create a new .md file in a 'posts' folder (e.g., /posts/my-new-post.md)
// 2. Add a new object to the `blogPosts` array below.
// =================================================================
const blogPosts = [
{
slug: 'my-first-post',
title: 'So, Why a Blog?',
date: 'July 13, 2025',
description: 'A quick word on why I’m starting this blog: mostly work and math, sometimes other things, no fixed schedule.',
path: 'posts/my-first-post.md'
}
];
// --- Function to render the list of blog posts ---
function renderBlogList() {
blogList.innerHTML = ''; // Clear existing list
const sortedPosts = [...blogPosts].sort((a, b) => new Date(b.date) - new Date(a.date));
sortedPosts.forEach(post => {
const article = document.createElement('article');
article.innerHTML = `
<div class="py-8 first:pt-0">
<h2 class="font-display text-2xl text-stone-900">
<a href="#blog/${post.slug}" class="hover:text-stone-600 post-link">${post.title}</a>
</h2>
<p class="text-xs uppercase tracking-widest text-stone-500 mt-2">${post.date}</p>
<p class="mt-3 text-stone-600">${post.description}</p>
<a href="#blog/${post.slug}" class="text-stone-900 underline underline-offset-4 decoration-stone-300 hover:decoration-stone-900 mt-4 inline-block post-link">Read More →</a>
</div>
`;
blogList.appendChild(article);
});
// Add event listeners to the new links
document.querySelectorAll('.post-link').forEach(link => {
link.addEventListener('click', handleRouting);
});
}
// --- Function to fetch and render a single blog post ---
async function renderBlogPost(slug) {
const post = blogPosts.find(p => p.slug === slug);
if (!post) {
blogPostContent.innerHTML = '<p>Post not found.</p>';
return;
}
try {
const response = await fetch(post.path);
if (!response.ok) {
throw new Error(`Could not fetch ${post.path}. Make sure the file exists.`);
}
const markdown = await response.text();
blogPostContent.innerHTML = marked.parse(markdown);
} catch (error) {
console.error('Error fetching post:', error);
blogPostContent.innerHTML = `<p class="text-red-500">Error: Could not load blog post. Check the console for details.</p>`;
}
}
// --- Main page navigation and routing logic ---
function showPage(pageId) {
pages.forEach(page => {
page.classList.toggle('hidden', page.id !== pageId);
});
window.scrollTo(0, 0); // Scroll to top on page change
}
function handleRouting() {
const hash = window.location.hash || '#home';
if (hash.startsWith('#blog/')) {
const slug = hash.substring(6); // Get slug from '#blog/slug'
showPage('blog');
blogListContainer.classList.add('hidden');
blogPostContainer.classList.remove('hidden');
renderBlogPost(slug);
} else if (hash === '#blog') {
showPage('blog');
blogListContainer.classList.remove('hidden');
blogPostContainer.classList.add('hidden');
renderBlogList(); // Render the list every time we navigate to the blog page
} else {
const pageId = hash.substring(1) || 'home';
showPage(pageId);
}
closeMobileMenu(); // Close menu after navigation
}
// --- Event Listeners ---
navLinks.forEach(link => {
link.addEventListener('click', handleRouting);
});
mobileNavLinks.forEach(link => {
link.addEventListener('click', handleRouting);
});
backToBlogBtn.addEventListener('click', () => {
window.location.hash = '#blog';
});
// Listen for hash changes (e.g., browser back/forward buttons)
window.addEventListener('hashchange', handleRouting);
// --- Initial Load ---
handleRouting(); // Call on initial page load
});
</script>
</body>
</html>