Skip to content

Commit

Permalink
fix(v2): add support dark logo for sidebar logo
Browse files Browse the repository at this point in the history
  • Loading branch information
lex111 committed Mar 21, 2020
1 parent c7101e0 commit 7a556d0
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import React, {useState, useCallback} from 'react';
import classnames from 'classnames';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import useThemeContext from '@theme/hooks/useThemeContext';
import useBaseUrl from '@docusaurus/useBaseUrl';
import useLockBodyScroll from '@theme/hooks/useLockBodyScroll';
import Link from '@docusaurus/Link';
Expand Down Expand Up @@ -116,8 +117,11 @@ function DocSidebar(props) {
const [showResponsiveSidebar, setShowResponsiveSidebar] = useState(false);
const {
siteConfig: {themeConfig: {navbar: {title, logo = {}} = {}}} = {},
isClient,
} = useDocusaurusContext();
const logoUrl = useBaseUrl(logo.src);
const {isDarkTheme} = useThemeContext();
const logoSrc = logo.srcDark && isDarkTheme ? logo.srcDark : logo.src;
const logoUrl = useBaseUrl(logoSrc);

const {
docsSidebars,
Expand Down Expand Up @@ -149,7 +153,7 @@ function DocSidebar(props) {
return (
<div className={styles.sidebar}>
<div className={styles.sidebarLogo}>
{logo != null && <img src={logoUrl} alt={logo.alt} />}
{logo != null && <img key={isClient} src={logoUrl} alt={logo.alt} />}
{title != null && <strong>{title}</strong>}
</div>
<div
Expand Down

0 comments on commit 7a556d0

Please sign in to comment.