-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
44 lines (38 loc) · 1.5 KB
/
app.js
File metadata and controls
44 lines (38 loc) · 1.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
// ainit.dev — Router
// Detects pathname, shows correct page, inits correct module.
const path = window.location.pathname;
// Page visibility
const howtoPage = document.getElementById('page-howto');
const aiignorePage = document.getElementById('page-aiignore');
const guardrailsPage = document.getElementById('page-guardrails');
// Hide all first
howtoPage.classList.add('hidden');
aiignorePage.classList.add('hidden');
guardrailsPage.classList.add('hidden');
if (path === '/how-to-use') {
howtoPage.classList.remove('hidden');
} else if (path === '/guardrails') {
guardrailsPage.classList.remove('hidden');
import('./guardrails.js').then(m => m.init());
} else {
aiignorePage.classList.remove('hidden');
import('./aiignore.js').then(m => m.init());
}
// Nav active state — desktop
document.querySelectorAll('.nav-link').forEach(link => {
const href = link.getAttribute('href');
const isActive = href === path || (href === '/' && path === '/');
link.classList.toggle('active', isActive);
link.classList.toggle('text-white', isActive);
link.classList.toggle('bg-white/5', isActive);
link.classList.toggle('text-muted', !isActive);
});
// Nav active state — mobile
document.querySelectorAll('.mobile-nav').forEach(link => {
const href = link.getAttribute('href');
const isActive = href === path || (href === '/' && path === '/');
if (isActive) {
link.classList.remove('bg-surface', 'text-muted', 'border-border');
link.classList.add('bg-accent', 'text-white', 'border-accent');
}
});