global: move home page and add logic for every page

This commit is contained in:
Agahnim 2026-03-24 14:32:08 +01:00
parent e8768265fb
commit ec8a28a230
Signed by: Agahnim
SSH key fingerprint: SHA256:Zj65PJnE0dRYye8Ltk/qDglynyXUxJngQ9qqx/VI+b4
3 changed files with 14 additions and 3 deletions

View file

@ -14,7 +14,7 @@ async fn main() {
let state = Arc::new(AppState::try_new().await);
let app = Router::new()
.route("/", get(home))
.route("/home", get(home))
.route("/music", get(music))
.nest_service("/static", ServeDir::new("static"))
.fallback(notfound)

View file

@ -48,12 +48,21 @@
document.querySelectorAll('navbar input[type="radio"]').forEach(radio => {
radio.checked = false;
});
if (path === '/') {
if (path === '/home') {
const homeRadio = document.getElementById('nav-home');
if (homeRadio) homeRadio.checked = true;
} else if (path === '/music') {
const musicRadio = document.getElementById('nav-music');
if (musicRadio) musicRadio.checked = true;
} else if (path === "/blog") {
const blogRadio = document.getElementById('nav-blog');
if (blogRadio) blogRadio.checked = true;
} else if (path === "/about") {
const aboutRadio = document.getElementById('nav-about');
if (aboutRadio) aboutRadio.checked = true;
} else if (path === "/projects") {
const projectsRadio = document.getElementById('nav-projects');
if (projectsRadio) projectsRadio.checked = true;
}
}

View file

@ -8,10 +8,12 @@
</label>
</navbar-toggle>
<navbar-content>
<a href="/">Home</a>
<a href="/home">Home</a>
<input type="radio" name="nav" id="nav-home" checked>
<a href="/about">About me</a>
<input type="radio" name="nav" id="nav-about">
<a href="/blog">Blog</a>
<input type="radio" name="nav" id="nav-blog">
<a href="/projects">Projects</a>
<input type="radio" name="nav" id="nav-projects">
<a href="/music">Music</a>