@@ -51,6 +51,7 @@ export type LinkProps = {
51
51
activeClassName ?: string ;
52
52
as ?: NextLinkProps [ 'as' ] ;
53
53
href : NextLinkProps [ 'href' ] ;
54
+ linkAs ?: NextLinkProps [ 'as' ] ; // Useful when the as prop is shallow by styled().
54
55
noLinkStyle ?: boolean ;
55
56
} & Omit < NextLinkComposedProps , 'to' | 'linkAs' | 'href' > &
56
57
Omit < MuiLinkProps , 'href' > ;
@@ -60,9 +61,10 @@ export type LinkProps = {
60
61
const Link = React . forwardRef < HTMLAnchorElement , LinkProps > ( function Link ( props , ref ) {
61
62
const {
62
63
activeClassName = 'active' ,
63
- as : linkAsProp ,
64
+ as : asProp ,
64
65
className : classNameProps ,
65
66
href,
67
+ linkAs : linkAsProp ,
66
68
noLinkStyle,
67
69
role, // Link don't have roles.
68
70
...other
@@ -86,12 +88,12 @@ const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(function Link(props,
86
88
return < MuiLink className = { className } href = { href } ref = { ref } { ...other } /> ;
87
89
}
88
90
89
- let linkAs = linkAsProp || ( href as string ) ;
91
+ let linkAs = linkAsProp || asProp || ( href as string ) ;
90
92
if (
91
93
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
95
97
) {
96
98
linkAs = `/${ userLanguage } ${ linkAs } ` ;
97
99
}
0 commit comments