/** * 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 React, {type ReactNode} from 'react'; import clsx from 'clsx'; import Link, {type Props as LinkProps} from '@docusaurus/Link'; import AuthorSocials from '@theme/Blog/Components/Author/Socials'; import type {Props} from '@theme/Blog/Components/Author'; import Heading from '@theme/Heading'; import styles from './styles.module.css'; function MaybeLink(props: LinkProps): ReactNode { if (props.href) { return ; } return <>{props.children}; } function AuthorTitle({title}: {title: string}) { return ( {title} ); } function AuthorName({name, as}: {name: string; as: Props['as']}) { if (!as) { return ( {name} ); } else { return ( {name} ); } } function AuthorBlogPostCount({count}: {count: number}) { return {count}; } // Note: in the future we might want to have multiple "BlogAuthor" components // Creating different display modes with the "as" prop may not be the best idea // Explainer: https://kyleshevlin.com/prefer-multiple-compositions/ // For now, we almost use the same design for all cases, so it's good enough export default function BlogAuthor({ as, author, className, count, }: Props): ReactNode { const {name, title, url, imageURL, email, page} = author; const link = page?.permalink || url || (email && `mailto:${email}`) || undefined; return (
{imageURL && ( {name} )} {(name || title) && (
{name && ( )} {count !== undefined && }
{!!title && } {/* We always render AuthorSocials even if there's none This keeps other things aligned with flexbox layout */}
)}
); }