@automattic/social-previews
Version:
A suite of components to generate previews for a post for both social and search engines.
17 lines (13 loc) • 500 B
text/typescript
import { firstValid, hardTruncation, shortEnough, stripHtmlTags, Formatter } from '../helpers';
const TITLE_LENGTH = 1000;
const DESCRIPTION_LENGTH = 400;
export const tumblrTitle: Formatter = ( text ) =>
firstValid(
shortEnough( TITLE_LENGTH ),
hardTruncation( TITLE_LENGTH )
)( stripHtmlTags( text ) ) || '';
export const tumblrDescription: Formatter = ( text ) =>
firstValid(
shortEnough( DESCRIPTION_LENGTH ),
hardTruncation( DESCRIPTION_LENGTH )
)( stripHtmlTags( text ) ) || '';