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: add useLink to NuxtLink #26522

Merged
merged 17 commits into from Apr 19, 2024
Merged

Conversation

userquin
Copy link
Member

@userquin userquin commented Mar 27, 2024

πŸ”— Linked issue

resolves #22169

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Check title: I need to add a test and include useLink type

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have added tests (if possible).
  • I have updated the documentation accordingly.

Copy link

stackblitz bot commented Mar 27, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@userquin
Copy link
Member Author

We need to move the second test to some fixture

@userquin userquin marked this pull request as ready for review March 29, 2024 16:49
vitest.nuxt.config.ts Outdated Show resolved Hide resolved
@@ -207,43 +280,11 @@ export function defineNuxtLink (options: NuxtLinkOptions) {
required: false,
},
},
useLink: useNuxtLink,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Member

@danielroe danielroe Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches RouterLink behaviour (which exposes a 'bound' composable which other libraries, like vuetify, can use to create custom links): https://router.vuejs.org/guide/advanced/composition-api.html#useLink.

@@ -120,6 +120,79 @@ export function defineNuxtLink (options: NuxtLinkOptions) {
return resolvedPath
}

function useNuxtLink (props: NuxtLinkProps) {
Copy link
Contributor

@harlan-zw harlan-zw Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI this logic has some legacy issues, see #25532

I wouldn't consider fixing them as part of this PR but it will likely be updated in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. ❀️ Just wanted to check that this implementation would be compatible with the tree-shaking/bundle size improvements you have in mind.

@harlan-zw
Copy link
Contributor

Looks good, nice job. Didn't sanity check all of the logic but if tests are passing it should be good 🀷

@danielroe danielroe merged commit 4dbe748 into nuxt:main Apr 19, 2024
36 checks passed
@github-actions github-actions bot mentioned this pull request Apr 19, 2024
@userquin userquin deleted the feat-add-use-link-to-nuxtlink branch April 19, 2024 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide RouterLink-compatible useLink method
3 participants