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: allow specifying custom target for FooterLogo #7557

Merged
merged 5 commits into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ describe('themeConfig', () => {
alt: 'Facebook Open Source Logo',
src: 'img/oss_logo.png',
href: 'https://opensource.facebook.com',
target: '_self',
},
copyright: `Copyright © ${new Date().getFullYear()} Facebook, Inc. Built with Docusaurus.`,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import React from 'react';
import Link from '@docusaurus/Link';
import {useBaseUrlUtils} from '@docusaurus/useBaseUrl';
import isInternalUrl from '@docusaurus/isInternalUrl';
import ThemedImage from '@theme/ThemedImage';
import type {Props} from '@theme/Footer/Logo';

Expand All @@ -31,8 +32,17 @@ function LogoImage({logo}: Props) {
}

export default function FooterLogo({logo}: Props): JSX.Element {
let logoLinkProps = {};
if (logo.target) {
logoLinkProps = {target: logo.target};
} else if (!isInternalUrl(logo.href)) {
logoLinkProps = {
rel: 'noopener noreferrer',
target: '_blank',
};
}
Josh-Cena marked this conversation as resolved.
Show resolved Hide resolved
return logo.href ? (
<Link href={logo.href} className={styles.footerLogoLink}>
<Link href={logo.href} className={styles.footerLogoLink} {...logoLinkProps}>
<LogoImage logo={logo} />
</Link>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ export const ThemeConfigSchema = Joi.object<ThemeConfig>({
width: Joi.alternatives().try(Joi.string(), Joi.number()),
height: Joi.alternatives().try(Joi.string(), Joi.number()),
href: Joi.string(),
target: Joi.string(),
}),
copyright: Joi.string(),
links: Joi.alternatives(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export type FooterLogo = {
srcDark?: string;
width?: string | number;
height?: string | number;
target?: string;
href?: string;
};

Expand Down