Skip to content

Commit

Permalink
feat(v2): allow to specify different logo for dark mode (#2261)
Browse files Browse the repository at this point in the history
* feat(v2): allow to specify different logo for dark mode

* Rename darkSrc with srcDark
  • Loading branch information
lex111 authored Feb 1, 2020
1 parent e224361 commit 9807552
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/docusaurus-theme-classic/src/theme/Navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ function Navbar() {
target: '_blank',
}
: null;
const logoImageUrl = useBaseUrl(logo.src);
const logoSrc = logo.srcDark && isDarkTheme ? logo.srcDark : logo.src;
const logoImageUrl = useBaseUrl(logoSrc);

return (
<nav
Expand Down
3 changes: 2 additions & 1 deletion website/docs/theme-classic.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = {

### Navbar Title & Logo

You can add a logo and title to the navbar via `themeConfig.navbar`. Logo can be placed in [static folder](static-assets.md). Logo URL is set to base URL of your site by default. Although you can specify your own URL for the logo, if it is an external link, it will open in a new tab.
You can add a logo and title to the navbar via `themeConfig.navbar`. Logo can be placed in [static folder](static-assets.md). Logo URL is set to base URL of your site by default. Although you can specify your own URL for the logo, if it is an external link, it will open in a new tab. You can also set a different logo for dark mode.

```js
// docusaurus.config.js
Expand All @@ -57,6 +57,7 @@ module.exports = {
logo: {
alt: 'Site Logo',
src: 'img/logo.svg',
srcDark: 'img/logo_dark.svg', // default to logo.src
href: 'https://v2.docusaurus.io/', // default to siteConfig.baseUrl
},
},
Expand Down

0 comments on commit 9807552

Please sign in to comment.