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

fix: Forces Link to expose the href to the child using passHref property. #2503

Merged
merged 3 commits into from Jul 9, 2017

Conversation

nihguy
Copy link
Contributor

@nihguy nihguy commented Jul 8, 2017

Fixes #1942 and other situations in which to expose the next/link href attribute for tag is necessary for avoiding problems with SEO.

The solution proposed by @arunoda, in the old #2475 solves the problem, adding a boolean passHref property to Link, forcing it to pass its href (or as) attribute to the child, when the correct type of tag can't be recognized.

It could be used like that:

import Link from 'next/link'
import Unexpected_A from 'third-library'

export default ({ href, name }) => (
  <Link href={href} passHref>
    <Unexpected_A>{ name }</Unexpected_A>
  </Link>
)

@arunoda
Copy link
Contributor

arunoda commented Jul 8, 2017

This is great.
I'd like to see following things:

  1. A section on README under here: https://github.com/zeit/next.js#with-link
  2. A simple test case somewhere here: https://github.com/zeit/next.js/blob/v3-beta/test/integration/basic/test/client-navigation.js#L35

Then let's take this.

@arunoda
Copy link
Contributor

arunoda commented Jul 9, 2017

This is awesome.

@arunoda arunoda merged commit 6e7ac5f into vercel:v3-beta Jul 9, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Aug 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants