Skip to content

Commit

Permalink
fix as for localized /api routes
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Nov 17, 2020
1 parent 04f821e commit 8499a91
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions docs/src/modules/components/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function Link(props) {
innerRef,
naked,
role: roleProp,
as: asProp = href,
...other
} = props;

Expand All @@ -42,8 +43,9 @@ function Link(props) {
[activeClassName]: router.pathname === href && activeClassName,
});

let linkAs = asProp;
if (userLanguage !== 'en' && href.indexOf('/') === 0 && href.indexOf('/blog') !== 0) {
other.as = `/${userLanguage}${href}`;
linkAs = `/${userLanguage}${linkAs}`;
}

// catch role passed from ButtonBase. This is definitely a link
Expand All @@ -60,11 +62,21 @@ function Link(props) {
}

if (naked) {
return <NextComposed className={className} href={href} ref={innerRef} role={role} {...other} />;
return (
<NextComposed
as={linkAs}
className={className}
href={href}
ref={innerRef}
role={role}
{...other}
/>
);
}

return (
<MuiLink
as={linkAs}
component={NextComposed}
className={className}
href={href}
Expand Down

0 comments on commit 8499a91

Please sign in to comment.