global: move home page and add logic for every page
This commit is contained in:
parent
e8768265fb
commit
ec8a28a230
3 changed files with 14 additions and 3 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue