@automattic/social-previews
Version:
A suite of components to generate previews for a post for both social and search engines.
15 lines • 799 B
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { hasTag, preparePreviewText } from '../helpers';
import { CUSTOM_TEXT_LENGTH } from './helpers';
const CustomText = ({ text, url, forceUrlDisplay }) => {
let postLink;
if (forceUrlDisplay || hasTag(text, 'a')) {
postLink = (_jsx("a", { className: "facebook-preview__custom-text-post-url", href: url, rel: "nofollow noopener noreferrer", target: "_blank", children: url }));
}
return (_jsxs("p", { className: "facebook-preview__custom-text", children: [_jsx("span", { children: preparePreviewText(text, {
platform: 'facebook',
maxChars: CUSTOM_TEXT_LENGTH,
}) }), postLink] }));
};
export default CustomText;
//# sourceMappingURL=custom-text.js.map