UNPKG

@automattic/social-previews

Version:

A suite of components to generate previews for a post for both social and search engines.

24 lines 2.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ThreadsPreviews = void 0; const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); const i18n_1 = require("@wordpress/i18n"); const section_heading_1 = tslib_1.__importDefault(require("../shared/section-heading")); const link_preview_1 = require("./link-preview"); const post_preview_1 = require("./post-preview"); const ThreadsPreviews = ({ headingLevel, hideLinkPreview, hidePostPreview, posts, }) => { if (!posts?.length) { return null; } return ((0, jsx_runtime_1.jsxs)("div", { className: "social-preview threads-preview", children: [!hidePostPreview && ((0, jsx_runtime_1.jsxs)("section", { className: "social-preview__section threads-preview__section", children: [(0, jsx_runtime_1.jsx)(section_heading_1.default, { level: headingLevel, children: // translators: refers to a social post on Threads (0, i18n_1.__)('Your post', 'social-previews') }), (0, jsx_runtime_1.jsx)("p", { className: "social-preview__section-desc", children: (0, i18n_1.__)('This is what your social post will look like on Threads:', 'social-previews') }), posts.map((post, index) => { const isLast = index + 1 === posts.length; return ((0, jsx_runtime_1.jsx)(post_preview_1.ThreadsPostPreview, { ...post, showThreadConnector: !isLast }, `threads-preview__post-${index}`)); })] })), !hideLinkPreview ? ((0, jsx_runtime_1.jsxs)("section", { className: "social-preview__section threads-preview__section", children: [(0, jsx_runtime_1.jsx)(section_heading_1.default, { level: headingLevel, children: // translators: refers to a link to a Threads post (0, i18n_1.__)('Link preview', 'social-previews') }), posts[0].image ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("p", { className: "social-preview__section-desc", children: (0, i18n_1.__)('This is what it will look like when someone shares the link to your WordPress post on Threads.', 'social-previews') }), (0, jsx_runtime_1.jsx)(link_preview_1.ThreadsLinkPreview, { ...posts[0], name: "", profileImage: "" })] })) : ((0, jsx_runtime_1.jsx)("p", { className: "social-preview__section-desc", children: (0, i18n_1.__)('Threads link preview requires an image to be set for the post. Please add an image to see the preview.', 'social-previews') }))] })) : null] })); }; exports.ThreadsPreviews = ThreadsPreviews; //# sourceMappingURL=previews.js.map