question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

In-component Navigation Guards

See original GitHub issue
  • I confirm that this is an issue rather than a question.

Bug report

Steps to reproduce

Create a global component with beforeRouteEnter, beforeRouteUpdate and beforeRouteLeave navigation guards.

https://codesandbox.io/embed/codesandbox-vuepress-navigation-guards-9iobr

What is expected?

The in-component navigation guards output to console.

What is actually happening?

The in-component navigation guards do not output.

Other relevant information

  • Output of npx vuepress info in my VuePress project:
Environment Info:

  System:
    OS: macOS High Sierra 10.13.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4960HQ CPU @ 2.60GHz
  Binaries:
    Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
    Yarn: 1.16.0 - ~/.yarn/bin/yarn
    npm: 6.10.2 - ~/.nvm/versions/node/v10.16.0/bin/npm
  Browsers:
    Chrome: 76.0.3809.100
    Firefox: 64.0
    Safari: 12.1.2
  npmPackages:
    @vuepress/core:  1.0.2 
    @vuepress/theme-default:  1.0.2 
    vuepress: 1.0.2 => 1.0.2 
  npmGlobalPackages:
    vuepress: Not Found

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
davestewartcommented, Mar 12, 2021

Sure. And sorry, wasn’t implying you’re a newcomer by the way! I’ve seen your themes.

Perhaps I should have said “you can also” rather than “you shouldn’t need to”.

Anyway, the reason I suggested $page is because you get access to both regularPath (the path of the physical page folder) and path; normally this is the same as $route.path, but is different if you’ve set a frontmatter permalink.

The reason I found this page is because I’m also building breadcrumbs (and I used $page.regularPath to do it):

image

Thanks for your explanation also.

😄

1reaction
Mister-Hopecommented, Mar 12, 2021

https://vuepress-theme-hope.github.io/guide/layout/breadcrumb/

This is what I build now.

Related files are under https://github.com/vuepress-theme-hope/vuepress-theme-hope/blob/v1/packages/components/src/client/BreadCrumb.ts

Finally use computers.

I was trying to build the whole structure through $site.pages, and even tring to cache the keys to fast update structure in an HMR.

Sadly that vuepress broke hmr in its updates.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Navigation Guards | Vue Router
As the name suggests, the navigation guards provided by Vue router are primarily used to guard navigations either by redirecting it or canceling...
Read more >
In Component Navigation Guards - A Vue.js Lesson From our ...
A navigation guard acts as a middleware that can protect a route component. We're also learning how to access data from child components...
Read more >
Protecting Vue Routes with Navigation Guards - CSS-Tricks
Navigation guards are a specific feature within Vue Router that provide additional functionality pertaining to how routes get resolved. They are ...
Read more >
How to implement route guard in vue.js | by Vipin Cheriyanveetil
I was recently developing an application vue.js and I came to this situation to implement route authentication or guard. Vue Router has few...
Read more >
Vue Router Router and Component Guards and Navigation ...
In this article, we'll look at defining route and in-component guards and look at the full navigation resolution flow.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found