Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

Conversation

@lihbr
Copy link
Member

@lihbr lihbr commented Mar 7, 2022

πŸ”— Linked issue

#2086

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 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)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

TODO:

  • Test

    next thing on my todo

  • Slot API

    can be delayed, not sure which way we want to go for this one πŸ€”

  • Documentation PR

    will work on it once the PR has stabilize

  • Prefetching support

    can be delayed, will need your help on it though

πŸ“ Checklist

@netlify
Copy link

netlify bot commented Mar 7, 2022

Copy link
Member Author

@lihbr lihbr left a comment

Choose a reason for hiding this comment

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

Alright, here's a first MVP of the <NuxtLink /> component. It includes the base component and tests for it as described in the RFC (#2086)

As mentioned in the PR first post here are the points that are missing to me now:

  1. Slot API: I think we need to discuss/agree on the desired API. It can also be postponed if needed and added later as a new feature.
  2. Documentation PR: I'll work on it when we're confident about this PR.
  3. Prefetching support: I'm not aware of the current status of Nuxt regarding this feature. If available I'll sync with @danielroe for some guidance, else we can wait for it or delay this feature.

ps. I'm not able to build bridge on Windows because symlinks like this one: https://github.com/nuxt/framework/blob/main/packages/bridge/src/runtime/asyncData.ts aren't supported there (or I'm doing something wrong). Because of that I'm not sure what the compiler really expects in the issue on the CI here: https://github.com/nuxt/framework/runs/5465287878?check_suite_focus=true Do you have any idea?

@pi0
Copy link
Member

pi0 commented Mar 8, 2022

Thanks for the updates @lihbr πŸ”₯ Adding replies here as cannot reply to outdated comment anymore:

I don't have a strong opinion on it but I tend to prefer it failing fast so that developers can handle the missing case quickly (checking if the link is available before rendering) rather than thinking links are working fine and discovering months after that they never did on production. Maybe # + a warning?

Both vue-router and HTML spec do not require href attribute for a tags: (https://html.spec.whatwg.org) and there is no downside associated with it. Sometimes links really don't exist for few items in a list!

If the a eleaceholder for where a link might otherwise have been placed, if it had been relevant.

Authors may also create an A element that specifies no anchors, i.e., that doesn't specify href, name, or id. Values for these attributes may be set at a later time through scripts.

Actually, I think it makes more sense to keep it as we still want people to be able to use defineNuxtLink({ externalRelAttribute: null }) or defineNuxtLink({ externalRelAttribute: "" }) to disable the framework's default rel attribute. But let me know!

Makese sense. Then at least can we please ignore both null and undefined equally as falsy values and allow one way (empty string) to disable default value with defineNuxtLink({ externalRelAttribute: "" }) ?

@lihbr
Copy link
Member Author

lihbr commented Mar 8, 2022

Both vue-router and HTML spec do not require href attribute for a tags: (html.spec.whatwg.org) and there is no downside associated with it. Sometimes links really don't exist for few items in a list!

OK indeed wasn't thinking about that. Should it default to "#" then? (rendering href="#") or null? (rendering no href attribute)

Makes sense. Then at least can we please ignore both null and undefined equally as falsy values and allow one way (empty string) to disable default value with defineNuxtLink({ externalRelAttribute: "" }) ?

I'm fine with it, the reason I was pushing for null was that null is the Vue way or saying "don't render the attribute". Should I proceed to exclude null?

@pi0
Copy link
Member

pi0 commented Mar 8, 2022

OK indeed wasn't thinking about that. Should it default to "#" then? (rendering href="#") or null? (rendering no href attribute)

null seems good idea!

@lihbr
Copy link
Member Author

lihbr commented Mar 10, 2022

I've been wondering if there's really a point to the href prop after all. It doesn't exist in Nuxt 2 and will be awkward to teach "Oh, btw, you can also use the href prop instead of the to one if that's more your jam, but if you use both, to will be preferred" πŸ€” The downside is that dropping it doesn't make <NuxtLink /> a drop-in replacement for the anchor tag anymore (href has to be translate to to).

We discussed it already with @pi0 there: https://github.com/nuxt/framework/discussions/2086#discussioncomment-1683859 (and I still don't really get it)

Actually I like it now that I'm writing doc. It's nice to define <NuxtLink /> as: "a drop-in replacement for both Vue Router's <RouterLink /> component and HTML's <a> tag" ☺️

@lihbr lihbr mentioned this pull request Mar 10, 2022
9 tasks
@lihbr
Copy link
Member Author

lihbr commented Mar 11, 2022

This looks like an already nice starter! What do you think is pending draft @lihbr ?

Hey there, indeed! I just synced with Daniel to fix the two last critical issues (bridge build failing + overwrite issue)

With that in mind, the <NuxtLink /> component and its documentation is quite ready IMO.

Slot API and prefetching feature can be postponed until available within the framework ☺️

@lihbr lihbr marked this pull request as ready for review March 11, 2022 12:09
Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

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

This is really nice! ❀️ A few tiny stylistic changes. I think merging the examples together would be helpful too.

}

describe('define-nuxt-link:to', () => {
it('renders link with `to` prop', () => {
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice if add e2e tests with basic fixture as well to test actual component's rendering behavior...

@pi0
Copy link
Member

pi0 commented Mar 14, 2022

Issue for prefetch support: nuxt/nuxt#13482

@pi0 pi0 changed the title feat(nuxt3): add <NuxtLink /> feat(nuxt3): add <NuxtLink> component Mar 14, 2022
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Amazing work πŸ”₯ Looking forward to the next steps!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants