@automattic/social-previews
Version:
A suite of components to generate previews for a post for both social and search engines.
15 lines • 701 B
JavaScript
import { firstValid, hardTruncation, shortEnough, stripHtmlTags, preparePreviewText, } from '../helpers';
const TITLE_LENGTH = 200;
const BODY_LENGTH = 300;
const URL_LENGTH = 40;
export const blueskyTitle = (text) => firstValid(shortEnough(TITLE_LENGTH), hardTruncation(TITLE_LENGTH))(stripHtmlTags(text)) || '';
export const blueskyBody = (text, options = {}) => {
const { offset = 0 } = options;
return preparePreviewText(text, {
platform: 'bluesky',
maxChars: BODY_LENGTH - URL_LENGTH - offset,
});
};
export const blueskyUrl = (text) => firstValid(shortEnough(URL_LENGTH), hardTruncation(URL_LENGTH))(stripHtmlTags(text)) ||
'';
//# sourceMappingURL=helpers.js.map