Skip to content

Commit

Permalink
fix: nextjs link on same page
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Oct 5, 2020
1 parent 7354ba7 commit c209272
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/starter/src/docs/first-page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ title: First Page

# My first doc page

other markdown
other markdown and jump the [section](#section)

# Section
8 changes: 8 additions & 0 deletions integrations/nextjs-plugin/src/components/NextLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ export const NextLink: FC<LinkProps & { to?: string }> = ({
children,
...props
}) => {
if (href.startsWith('#')) {
return (
<a href={href} {...props}>
{children}
</a>
);
}

const urlparts = href.split('/');
const isHomePage =
urlparts.length === 2 && urlparts[0] === '' && urlparts[1] === '';
Expand Down

0 comments on commit c209272

Please sign in to comment.