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

Add config to make link interception opt-in #918

Closed
brillout opened this issue May 27, 2023 · 4 comments
Closed

Add config to make link interception opt-in #918

brillout opened this issue May 27, 2023 · 4 comments
Labels
enhancement ✨ New feature or request

Comments

@brillout
Copy link
Member

Description

By default, when using Client Routing, vite-plugin-ssr automatically intercepts links. You can opt-out with rel="external" (e.g. <a href="/admin" rel="external">).

Instead of opt-out, there could be a new config disableAutomaticLinkInterception, together with a new attribute data-vike-link to opt into Client Routing (e.g. <a href="/product/42" data-vike-link>).

The config can be set in a non-global fashion, i.e. each page can have a different disableAutomaticLinkInterception setting.

// /dashboard/+config.js

// The links displayed at URL `/dashboard` *aren't* intercepted 
export default {
  disableAutomaticLinkInterception: true
}
// /product/@id/+config.js

// The links displayed at URL `/product/42` *are* intercepted 
export default {
  disableAutomaticLinkInterception: false
}
@brillout brillout added the enhancement ✨ New feature or request label May 27, 2023
@jahredhope
Copy link

I think this feature would be really valuable.

I raised my reasoning previously in #728

@brillout
Copy link
Member Author

ETA this week.

@brillout
Copy link
Member Author

brillout commented Jun 4, 2023

Implemented. Set window._disableAutomaticLinkInterception = true and use <a data-vike-link>.

⚠️ _disableAutomaticLinkInterception will be removed in the next major release. Because, in the next major release, the link interceptor will be able to check whether the URL matches the route of a page, making _disableAutomaticLinkInterception obsolete. (The change requires a breaking change and that's why it can't be released already as v0.4.x.)

@brillout
Copy link
Member Author

brillout commented Jun 4, 2023

Pre-released in 0.4.131-commit-35ca471f7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants