Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(client): add VPLink and RouterLink #1353

Closed
wants to merge 7 commits into from
Closed

Conversation

Mister-Hope
Copy link
Member

@Mister-Hope Mister-Hope commented Jun 8, 2023

@vuepress/client

  • new useResolvedRoute composables (with redirects support)

two replacement for <RouterLink> in vue-router:

  • new <VPLink> component, do not resolve any route during initialization.
  • new <RouterLink> component, handling redirects and reduce router.resolve cost comparing with official <RouterLink> and active state with vp-active

@vuepress/markdown

  • support and use <VPLink> by default for links plugin

@vuepress/shared

  • new inferRoutePath function to avoid possible redirect matching that needs to call router.resolve again

Documentation

All related api docs update

Performance

( under 6x slowdown mocking withofficial docs)

Original:

Before:

image

After:

image

Adding 1000 pages on official docs:

  // all pages have been loaded after initialization
  onInitialized: async (app) => {
    for (let i = 1; i < 1000; i++) {
      const homepage = await createPage(app, {
        path: `/${i}`,
        // set frontmatter
        frontmatter: {
          layout: 'Layout',
        },
        // set markdown content
        content: `\
# Welcome to ${app.options.title}

This is page ${i}
`,
      })
      // add it to `app.pages`
      app.pages.push(homepage)
    }
  },

Before:
image

image

After:
image

image

@Mister-Hope Mister-Hope linked an issue Jun 8, 2023 that may be closed by this pull request
@Mister-Hope Mister-Hope force-pushed the router-link branch 2 times, most recently from e597410 to f7245d7 Compare June 9, 2023 11:37
@meteorlxy
Copy link
Member

meteorlxy commented Jul 3, 2023

So the new <RouterLink> is not actually in use, right?

Is it possible to get rid of both new and old <RouterLink>? If so, I think it's better to use <VPLink> to replace the <RouterLink> totally.

My concern is to reduce user's confusion about the three different link components.

@Mister-Hope
Copy link
Member Author

Screenshot_2023-07-04-11-00-06-08_320a9a695de7cdce83ed5281148d6f19.jpg

@Mister-Hope
Copy link
Member Author

Mister-Hope commented Jul 4, 2023

I think we can stop providing the official router-link and use ours instead. But that could be a breaking change.

The router link component should be kept as we do care about active state and the exact href location sometimes.

With this, users should import the real routerlink and overide ours if they do want the official one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Performance] Avoid using router-link
2 participants