UNPKG

@automattic/social-previews

Version:

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

16 lines 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.facebookDescription = exports.facebookTitle = exports.baseDomain = exports.CUSTOM_TEXT_LENGTH = void 0; const helpers_1 = require("../helpers"); const TITLE_LENGTH = 110; const DESCRIPTION_LENGTH = 200; exports.CUSTOM_TEXT_LENGTH = 440; const baseDomain = (url) => url .replace(/^[^/]+[/]*/, '') // strip leading protocol .replace(/\/.*$/, ''); // strip everything after the domain exports.baseDomain = baseDomain; const facebookTitle = (text) => (0, helpers_1.firstValid)((0, helpers_1.shortEnough)(TITLE_LENGTH), (0, helpers_1.hardTruncation)(TITLE_LENGTH))((0, helpers_1.stripHtmlTags)(text)) || ''; exports.facebookTitle = facebookTitle; const facebookDescription = (text) => (0, helpers_1.firstValid)((0, helpers_1.shortEnough)(DESCRIPTION_LENGTH), (0, helpers_1.hardTruncation)(DESCRIPTION_LENGTH))((0, helpers_1.stripHtmlTags)(text)) || ''; exports.facebookDescription = facebookDescription; //# sourceMappingURL=helpers.js.map