Skip to content

How to change Navbar links by route? #1295

Answered by andyslack
andyslack asked this question in Q&A
Discussion options

You must be logged in to vote

I have managed to get an MVP working using the following code:

import { defineClientConfig } from '@vuepress/client'
import {homeNavbar} from "./theme/config/home";
import {quasarNavbar} from "./theme/config/frontend/quasar";

export default defineClientConfig({
	enhance({ app, router }) {

		router.afterEach((to) => {

			if (to.path === '/') {
				app.config.globalProperties.$theme.navbar = homeNavbar
			}

			if (to.path.includes('/frontend/quasar')) {
				app.config.globalProperties.$theme.navbar = quasarNavbar
			}

		})
	}
})

Hope it helps someone.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Mister-Hope
Comment options

Answer selected by Mister-Hope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants