diff --git a/packages/theme-nonepress/src/theme/Logo/index.tsx b/packages/theme-nonepress/src/theme/Logo/index.tsx index cb29d81..2efeb8b 100644 --- a/packages/theme-nonepress/src/theme/Logo/index.tsx +++ b/packages/theme-nonepress/src/theme/Logo/index.tsx @@ -17,29 +17,46 @@ function LogoThemedImage({ logo: NavbarLogo; alt: string; imageClassName?: string; -}) { - const sources = { - light: useBaseUrl(logo.src), - dark: useBaseUrl(logo.srcDark || logo.src), - }; - const themedImage = ( - - ); +}): JSX.Element { + const lightSrc = useBaseUrl(logo.src); + const darkSrc = useBaseUrl(logo.srcDark || logo.src); // Is this extra div really necessary? // introduced in https://github.com/facebook/docusaurus/pull/5666 - return imageClassName ? ( -
{themedImage}
- ) : ( - themedImage - ); + const wrapper = (children: JSX.Element): JSX.Element => + imageClassName ? ( +
{children}
+ ) : ( + children + ); + + if (logo.srcDark == null) { + return wrapper( + {alt}, + ); + } else { + const sources = { + light: lightSrc, + dark: darkSrc, + }; + return wrapper( + , + ); + } } export default function Logo(props: Props): JSX.Element {