Skip to content
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { Fragment } from "react";
import styled from "styled-components";
import PropTypes from "prop-types";
import { __, sprintf } from "@wordpress/i18n";
import { isString } from "lodash";

/* Internal dependencies */
import FacebookAuthorName from "./FacebookAuthorName";
Expand Down Expand Up @@ -59,11 +60,13 @@ function renderFacebookAuthorName( authorName ) {
* Renders a FacebookSiteAndAuthorNames component.
*
* @param {object} props The props.
* @param {string} props.authorName The author's name.
* @param {string} props.siteUrl The site url.
*
* @returns {React.Element} The rendered element.
*/
const FacebookSiteAndAuthorNames = ( props ) => {
const hasAuthorName = props.authorName.length > 0;
const hasAuthorName = isString( props.authorName ) && props.authorName.length > 0;
const screenReaderText = hasAuthorName
/* Translators: 1: site name, 2: post author name */
? sprintf( __( "%1$s by %2$s", "yoast-components" ), props.siteUrl, props.authorName )
Expand Down