@@ -51,6 +51,7 @@ export type LinkProps = {
5151 activeClassName ?: string ;
5252 as ?: NextLinkProps [ 'as' ] ;
5353 href : NextLinkProps [ 'href' ] ;
54+ linkAs ?: NextLinkProps [ 'as' ] ; // Useful when the as prop is shallow by styled().
5455 noLinkStyle ?: boolean ;
5556} & Omit < NextLinkComposedProps , 'to' | 'linkAs' | 'href' > &
5657 Omit < MuiLinkProps , 'href' > ;
@@ -60,9 +61,10 @@ export type LinkProps = {
6061const Link = React . forwardRef < HTMLAnchorElement , LinkProps > ( function Link ( props , ref ) {
6162 const {
6263 activeClassName = 'active' ,
63- as : linkAsProp ,
64+ as : asProp ,
6465 className : classNameProps ,
6566 href,
67+ linkAs : linkAsProp ,
6668 noLinkStyle,
6769 role, // Link don't have roles.
6870 ...other
@@ -86,12 +88,12 @@ const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(function Link(props,
8688 return < MuiLink className = { className } href = { href } ref = { ref } { ...other } /> ;
8789 }
8890
89- let linkAs = linkAsProp || ( href as string ) ;
91+ let linkAs = linkAsProp || asProp || ( href as string ) ;
9092 if (
9193 userLanguage !== 'en' &&
92- typeof href === 'string' &&
93- href . indexOf ( '/' ) === 0 &&
94- href . indexOf ( '/blog' ) !== 0
94+ pathname &&
95+ pathname . indexOf ( '/' ) === 0 &&
96+ pathname . indexOf ( '/blog' ) !== 0
9597 ) {
9698 linkAs = `/${ userLanguage } ${ linkAs } ` ;
9799 }
0 commit comments