Vuepress redirect to external url

Vuepress redirect to external url

Apr 10, 2022 4:00 PM (3 years ago)

If you want vuepress to redirect urls to any website here's how you do it 👇

Link Preview

I wanted to create short urls that links to my social media and other external websites.

✅ In enhanceApp.js file add or insert the following snippet

export default ({ Vue, options, router }) => {

	router.addRoutes([
		{
			path: '/facebook-group', // the url users will visit
			beforeEnter(to, from, next) {
                // you can add analysis or logging stuff here

                // url user will be redirected to 👇
				window.location.href = 'https://www.facebook.com/groups/laravel.arabic';
			},
		},
	]);

}

⚠ Update addRoutes is deprecated in vue router 4 use addRoute instad 👇

export default ({ Vue, options, router }) => {

	router.addRoute(
		{
			path: '/facebook-group', // the url users will visit
			beforeEnter(to, from, next) {
                // you can add analysis or logging stuff here

                // url user will be redirected to 👇
				window.location.href = 'https://www.facebook.com/groups/laravel.arabic';
			},
		},
]);

}
My Newsletter

I send out an email every so often about cool stuff I'm working on or launching. If you dig, go ahead and sign up!

No spam, only goldden nuggets 💎

Comments

Ahmed Nagi - Powerd By Vuepress . Hosted with GitHub and Netlify .