fix(v2): properly set dark mode logo on build-time prerendering (#2324)

This commit is contained in:
Alexey Pyltsyn 2020-02-27 05:16:40 +03:00 committed by GitHub
parent 37dff050ce
commit 6670c53d18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -51,8 +51,7 @@ function NavLink({activeBasePath, to, href, label, position, ...props}) {
} }
function Navbar() { function Navbar() {
const context = useDocusaurusContext(); const {siteConfig = {}, isClient} = useDocusaurusContext();
const {siteConfig = {}} = context;
const {baseUrl, themeConfig = {}} = siteConfig; const {baseUrl, themeConfig = {}} = siteConfig;
const {navbar = {}, disableDarkMode = false} = themeConfig; const {navbar = {}, disableDarkMode = false} = themeConfig;
const {title, logo = {}, links = [], hideOnScroll = false} = navbar; const {title, logo = {}, links = [], hideOnScroll = false} = navbar;
@ -124,7 +123,12 @@ function Navbar() {
</div> </div>
<Link className="navbar__brand" to={logoLink} {...logoLinkProps}> <Link className="navbar__brand" to={logoLink} {...logoLinkProps}>
{logo != null && ( {logo != null && (
<img className="navbar__logo" src={logoImageUrl} alt={logo.alt} /> <img
key={isClient}
className="navbar__logo"
src={logoImageUrl}
alt={logo.alt}
/>
)} )}
{title != null && ( {title != null && (
<strong <strong
@ -172,7 +176,12 @@ function Navbar() {
to={logoLink} to={logoLink}
{...logoLinkProps}> {...logoLinkProps}>
{logo != null && ( {logo != null && (
<img className="navbar__logo" src={logoImageUrl} alt={logo.alt} /> <img
key={isClient}
className="navbar__logo"
src={logoImageUrl}
alt={logo.alt}
/>
)} )}
{title != null && <strong>{title}</strong>} {title != null && <strong>{title}</strong>}
</Link> </Link>