1- import React from 'react' ;
1+ import React , { Fragment , useContext } from 'react' ;
22
33import { Image } from '../../../components' ;
44import { getMediaImage } from '../../../components/Media/Image/utils' ;
55import RouterLink from '../../../components/RouterLink/RouterLink' ;
6+ import { LocationContext } from '../../../context/locationContext' ;
67import { useTheme } from '../../../context/theme' ;
78import { ThemedNavigationLogoData } from '../../../models' ;
8- import { block , getThemedValue } from '../../../utils' ;
9+ import { block , getLinkProps , getThemedValue } from '../../../utils' ;
910
1011import './Logo.scss' ;
1112
@@ -16,17 +17,35 @@ export type LogoProps = ThemedNavigationLogoData & {
1617} ;
1718
1819const Logo : React . FC < LogoProps > = ( props ) => {
20+ const { hostname, Link} = useContext ( LocationContext ) ;
1921 const theme = useTheme ( ) ;
2022 const themedLogoProps = getThemedValue ( props , theme ) || props ;
2123 const imageData = getMediaImage ( themedLogoProps . icon || props . icon ) ;
2224 const textData = themedLogoProps . text || props . text ;
25+ const url = themedLogoProps . url || props . url || '/' ;
26+ const urlTitle = themedLogoProps . urlTitle || props . urlTitle || textData ;
27+ const linkExtraProps = getLinkProps ( url , hostname ) ;
28+ const content = (
29+ < Fragment >
30+ { imageData && < Image className = { b ( 'icon' ) } { ...imageData } /> }
31+ < span className = { b ( 'text' ) } > { textData } </ span >
32+ </ Fragment >
33+ ) ;
2334
2435 return (
25- < RouterLink href = { themedLogoProps . url || props . url || '/' } passHref >
26- < div className = { b ( null , props . className ) } >
27- { imageData && < Image className = { b ( 'icon' ) } { ...imageData } /> }
28- < span className = { b ( 'text' ) } > { textData } </ span >
29- </ div >
36+ < RouterLink href = { url } passHref >
37+ { Link ? (
38+ < span className = { b ( null , props . className ) } > { content } </ span >
39+ ) : (
40+ < a
41+ className = { b ( null , props . className ) }
42+ href = { url }
43+ title = { urlTitle }
44+ { ...linkExtraProps }
45+ >
46+ { content }
47+ </ a >
48+ ) }
3049 </ RouterLink >
3150 ) ;
3251} ;
0 commit comments