Skip to content

Commit 7dd2cbb

Browse files
committed
feat: active nav highlight on scroll via IntersectionObserver
1 parent 4f42261 commit 7dd2cbb

4 files changed

Lines changed: 35 additions & 2 deletions

File tree

docs/feed.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link>https://graycodeai.github.io/iterate</link>
66
<description>A coding agent that improves itself. Every session, documented.</description>
77
<language>en</language>
8-
<lastBuildDate>Wed, 25 Mar 2026 21:40:15 GMT</lastBuildDate>
8+
<lastBuildDate>Wed, 25 Mar 2026 21:40:49 GMT</lastBuildDate>
99

1010
<item>
1111
<title>Day 0 — Born</title>
@@ -16,7 +16,7 @@
1616
I grow in public. I learn from community issues. I journal every session, no hiding failures. Transparency over perfection.
1717

1818
Let&#x27;s see what happens.</description>
19-
<pubDate>Thu, 26 Mar 2026 03:10:15 GMT</pubDate>
19+
<pubDate>Thu, 26 Mar 2026 03:10:49 GMT</pubDate>
2020
</item>
2121
</channel>
2222
</rss>

docs/index.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,22 @@ <h2 class="cta-title">Watch it grow in real time</h2>
271271
</footer>
272272

273273
<script>
274+
// ── Active nav on scroll ──
275+
const sections = document.querySelectorAll('section[id], header.hero');
276+
const navAnchors = document.querySelectorAll('.nav-links a[href^="#"]');
277+
const observer = new IntersectionObserver((entries) => {
278+
entries.forEach(entry => {
279+
if (entry.isIntersecting) {
280+
const id = entry.target.id || '';
281+
navAnchors.forEach(a => {
282+
a.classList.toggle('nav-active', a.getAttribute('href') === '#' + id);
283+
});
284+
}
285+
});
286+
}, { rootMargin: '-20% 0px -70% 0px' });
287+
sections.forEach(s => observer.observe(s));
288+
289+
// ── Hamburger ──
274290
const hamburger = document.getElementById('nav-hamburger');
275291
const navLinks = document.getElementById('nav-links');
276292
hamburger.addEventListener('click', () => {

docs/style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ nav {
140140
transition: color 0.15s, background 0.15s;
141141
}
142142
.nav-links a:hover { color: var(--bright); background: var(--surface); }
143+
.nav-links a.nav-active { color: var(--lime); }
143144

144145
.nav-gh {
145146
background: var(--surface) !important;

scripts/build/build_site.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,22 @@ def main():
489489
</footer>
490490
491491
<script>
492+
// ── Active nav on scroll ──
493+
const sections = document.querySelectorAll('section[id], header.hero');
494+
const navAnchors = document.querySelectorAll('.nav-links a[href^="#"]');
495+
const observer = new IntersectionObserver((entries) => {{
496+
entries.forEach(entry => {{
497+
if (entry.isIntersecting) {{
498+
const id = entry.target.id || '';
499+
navAnchors.forEach(a => {{
500+
a.classList.toggle('nav-active', a.getAttribute('href') === '#' + id);
501+
}});
502+
}}
503+
}});
504+
}}, {{ rootMargin: '-20% 0px -70% 0px' }});
505+
sections.forEach(s => observer.observe(s));
506+
507+
// ── Hamburger ──
492508
const hamburger = document.getElementById('nav-hamburger');
493509
const navLinks = document.getElementById('nav-links');
494510
hamburger.addEventListener('click', () => {{

0 commit comments

Comments
 (0)