docusaurus/packages/docusaurus-theme-bootstrap/src/theme/hooks/useLogo.js
Fanny 7d8aeacf52
feat(v2): bootstrap layout navbar (#2668)
* feat(v2): add minor adjustements and footer component

* fix(v2): margin and spacing of footer

* feat(v2): add navbar component

* ádd collapse classname

* feat(v2): add dependencies

* feat(v2): remove unused code

* feat(v2): remove unused links

* feat(v2): add reactstrap components :|

* feat(v2): add brand and other nav componnets
2020-05-13 11:24:53 +08:00

41 lines
1.1 KiB
JavaScript

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import useThemeContext from '@theme/hooks/useThemeContext';
import useBaseUrl from '@docusaurus/useBaseUrl';
import isInternalUrl from '@docusaurus/isInternalUrl';
const useLogo = () => {
const {
siteConfig: {baseUrl, themeConfig: {navbar: {logo = {}} = {}}} = {},
} = useDocusaurusContext();
const {isDarkTheme} = useThemeContext();
const logoLink = logo.href || baseUrl;
let logoLinkProps = {};
if (logo.target) {
logoLinkProps = {target: logo.target};
} else if (!isInternalUrl(logoLink)) {
logoLinkProps = {
rel: 'noopener noreferrer',
target: '_blank',
};
}
const logoSrc = logo.srcDark && isDarkTheme ? logo.srcDark : logo.src;
const logoImageUrl = useBaseUrl(logoSrc);
return {
logoLink,
logoLinkProps,
logoImageUrl,
logoAlt: logo.alt,
};
};
export default useLogo;