/** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ import { EditIcon } from '../../common/icons/edit-icon'; import { OpenLinkIcon } from '../../common/icons/open-link-icon'; import { getSmartShortDate } from '../../common/utils/date'; import { PostData, PostListItemMetric, PostListItemProps, getPostEditUrl, } from '../../common/utils/post'; /** * Defines the props structure for components receiving only post data. * * @since 3.10.0 */ interface TopPostDataProps { post: PostData; } /** * Returns a single list item depicting a post. * * @param {PostListItemProps} props The component's props. */ export function TopPostListItem( { metric, post }: Readonly ): React.JSX.Element { return (
  • { __( 'View Post (opens in new tab)', 'wp-parsely' ) } { 0 !== post.postId && { __( 'Edit Post (opens in new tab)', 'wp-parsely' ) } }
    { __( 'Date', 'wp-parsely' ) } { getSmartShortDate( new Date( post.date ) ) } { __( 'Author', 'wp-parsely' ) } { post.author }
  • ); } /** * Returns the Post thumbnail with its div container. Returns an empty div if * the post has no thumbnail. * * @param {PostData} post The Post from which to get the data. */ function ListItemThumbnail( { post }: Readonly ): React.JSX.Element { if ( post.thumbnailUrl ) { return (
    { __( 'Thumbnail', 'wp-parsely' ) } {
    ); } return (
    { __( 'Post thumbnail not available', 'wp-parsely' ) }
    ); } /** * Returns the Post title as a link (for editing the Post) or a div if the Post * has no valid ID. * * @param {TopPostDataProps} props The component's props. */ function PostListItemTitle( { post }: Readonly ): React.JSX.Element { return ( { __( 'View in Parse.ly (opens in new tab)', 'wp-parsely' ) } { post.title } ); }