Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(v2): allow to specify different logo for dark mode #2261

Merged
merged 2 commits into from
Feb 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.darkSrc && isDarkTheme ? logo.darkSrc : logo.src;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe is it better to move this expression to the hook call?

const logoImageUrl = useBaseUrl(logo.darkSrc && isDarkTheme ? logo.darkSrc : logo.src);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both are acceptable.

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',
darkSrc: 'img/logo_dark.svg', // default to logo.src
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe is it better to rename to srcDark or just dark?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think srcDark would be better.

href: 'https://v2.docusaurus.io/', // default to siteConfig.baseUrl
},
},
Expand Down