@automattic/social-previews
Version:
A suite of components to generate previews for a post for both social and search engines.
19 lines • 1.85 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { __ } from '@wordpress/i18n';
import SectionHeading from '../shared/section-heading';
import { TwitterLinkPreview } from './link-preview';
import { TwitterPostPreview } from './post-preview';
export const TwitterPreviews = ({ headingLevel, hideLinkPreview, hidePostPreview, tweets, }) => {
if (!tweets?.length) {
return null;
}
return (_jsxs("div", { className: "social-preview twitter-preview", children: [!hidePostPreview && (_jsxs("section", { className: "social-preview__section twitter-preview__section", children: [_jsx(SectionHeading, { level: headingLevel, children:
// translators: refers to a social post on Twitter
__('Your post', 'social-previews') }), _jsx("p", { className: "social-preview__section-desc", children: __('This is what your social post will look like on X:', 'social-previews') }), tweets.map((tweet, index) => {
const isLast = index + 1 === tweets.length;
return (_jsx(TwitterPostPreview, { ...tweet, showThreadConnector: !isLast }, `twitter-preview__tweet-${index}`));
})] })), !hideLinkPreview && (_jsxs("section", { className: "social-preview__section twitter-preview__section", children: [_jsx(SectionHeading, { level: headingLevel, children:
// translators: refers to a link to a Twitter post
__('Link preview', 'social-previews') }), _jsx("p", { className: "social-preview__section-desc", children: __('This is what it will look like when someone shares the link to your WordPress post on X.', 'social-previews') }), _jsx(TwitterLinkPreview, { ...tweets[0], name: "", profileImage: "", screenName: "" })] }))] }));
};
//# sourceMappingURL=previews.js.map