mark active page on menu

This commit is contained in:
2024-12-21 17:46:54 +01:00
parent dde5da47c1
commit 414404a045
2 changed files with 38 additions and 2 deletions
+37 -2
View File
@@ -2,10 +2,10 @@
<nav class="menu">
<ul>
<li>
<router-link to="/dashboard">Dashboard</router-link>
<router-link to="/dashboard" active-class="active">Dashboard</router-link>
</li>
<li v-if="!isLoggedIn">
<router-link to="/register">Register</router-link>
<router-link to="/register" active-class="active">Register</router-link>
</li>
<li v-if="isLoggedIn">
<button @click="logout">Logout</button>
@@ -31,3 +31,38 @@ export default {
},
};
</script>
<style>
.menu {
background-color: #333;
color: white;
padding: 1rem;
}
.menu ul {
list-style: none;
display: flex;
gap: 1rem;
}
.menu a {
color: white;
text-decoration: none;
}
.menu a:hover {
text-decoration: underline;
}
.menu .active {
font-weight: bold;
text-decoration: underline;
}
.menu button {
background: none;
border: none;
color: white;
cursor: pointer;
}
</style>
+1
View File
@@ -15,6 +15,7 @@ const routes = [
const router = createRouter({
history: createWebHistory(),
routes,
//linkActiveClass: "current-page", // Custom active class
});
// Navigation guard