Skip to content

Dynamically create the items of a NavBar #11649

Discussion options

You must be logged in to vote

so what about using watch here to keep an eye on the auth state and update the links when it changes? Something like this:

<script setup>
import { Link, usePage } from '@inertiajs/vue3';
import { ref, computed, watch } from 'vue';
import Dropdown from '@/Components/Dropdown.vue';
import { IconSun, IconMoonStars, IconDeviceDesktopCog } from '@tabler/icons-vue';

const page = usePage();

const isAuthenticated = computed(() => !!page.props.auth.user);
const user = computed(() => page.props.auth.user);

const baseNavbarLinks = computed(() => [
    { name: 'Home', route: 'home' },
    { name: 'About', route: 'about' },
    { name: 'Contact', route: 'contact' },
]);

const authNavbarLinks = com…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@HeytalePazguato
Comment options

Answer selected by HeytalePazguato
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants