question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to disable auto withPrefix at Link component by manual

See original GitHub issue

Is it possible to disable auto withPrefix at Link component by manual?

just like this code

<Link to={'link'} disablePrefix={true}>link</Link>

why need this feature?

I use gatsby-plugin-mdx , and need to rewrap a component to Link with custom style. When building with the prefix path, the link in mdx is broken.

The demo repo

gatsby new testgatsbylink suziwen/testgatsbylink
cd testgatsbylink
gatsby build --prefix-paths
gatsby serve --prefix-paths

goto http://localhost:9000/testlink you will see test link is broken. The href value becomes http://localhost:9000/testlink/testlink/link .

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
suziwencommented, Apr 15, 2020

The Link’s to value is from mdx, which is already withPrefix. If I want to rewrap a component to Link with custom style, and Link component doesn’t have the option to disable withPrefix, I need manually remove the prefix path of to value.

const StyleLink = ({href, children, ...props})=>{
  const to = props.to || href
  return (
    <Link
      {...props}
      to={to}
      activeClassName="active"
    >
      {children}
    </Link>
  )
}

const components = {
  a: StyleLink
}

export default ()=> {
  return (
    <div>
      <MDXProvider components={components}>
        <Content />
      </MDXProvider>
    </div>
  )
}
0reactions
github-actions[bot]commented, Jul 11, 2020

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else. As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! 💪💜

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-router: How to disable a <Link>, if its active?
The How to disable HTML links answer attached suggested using both disabled and pointer-events: none for maximum browser-support.
Read more >
Gatsby Link API
Gatsby lets you set the path prefix for your site. After doing so, Gatsby's <Link> component will automatically handle constructing the correct URL...
Read more >
gcc(1) - Linux manual page - man7.org
When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The "overall options" allow you to stop this process at an...
Read more >
D-Link DIR-866L User Manual
D-Link DIR-866L User Manual. Section 2 - Installation. 1. Turn off and unplug the power to your DSL or cable modem. This is...
Read more >
Using the Gatsby Link Component to Navigate Between Pages
How to navigate between pages of your Gatsby website using the Link component, which makes it easy to style when the page is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found