Skip to content

Commit

Permalink
Use useRoute() instead $route
Browse files Browse the repository at this point in the history
  • Loading branch information
louderthan10 committed Nov 28, 2024
1 parent 8a43cd0 commit d54bcfb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions frontend/components/navigation.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<script setup>
const route = useRoute()
defineProps({
pages: {
type: Array,
default: () => []
}
})
const isCurrentPage = (path) => route.path === path
</script>

<template>
Expand All @@ -15,7 +19,7 @@ defineProps({
to="/blog"
class="block p-2 hover:underline text-red-600 hover:text-red-600"
active-class="text-red-600"
:aria-current="$route.path === '/blog' ? 'page' : null"
:aria-current="isCurrentPage('/blog') ? 'page' : null"
>
Blog
</NuxtLink>
Expand All @@ -25,7 +29,7 @@ defineProps({
to="/guestbook"
class="block p-2 hover:underline text-red-600 hover:text-red-600"
active-class="text-red-600"
:aria-current="$route.path === '/guestbook' ? 'page' : null"
:aria-current="isCurrentPage('/guestbook') ? 'page' : null"
>
Guestbook
</NuxtLink>
Expand All @@ -35,7 +39,7 @@ defineProps({
:to="`/${page.uri}`"
class="block p-2 hover:underline text-red-600 hover:text-red-600"
active-class="text-red-600"
:aria-current="$route.path === `/${page.uri}` ? 'page' : null"
:aria-current="isCurrentPage(`/${page.uri}`) ? 'page' : null"
>
{{ page.title }}
</NuxtLink>
Expand Down

0 comments on commit d54bcfb

Please sign in to comment.