Skip to content
Snippets Groups Projects
Commit 35bab195 authored by Quoc Huy Nguyen Dinh's avatar Quoc Huy Nguyen Dinh
Browse files

Increase length of post summary when derived from the post body to allow CSS...

Increase length of post summary when derived from the post body to allow CSS ellipsis to fill the container
parent 71a7d752
Branches
No related tags found
2 merge requests!216Develop,!214Make the content block text container to go full width
...@@ -8,12 +8,7 @@ import _ from 'lodash'; ...@@ -8,12 +8,7 @@ import _ from 'lodash';
const remarkable = new Remarkable({ html: true, linkify: false }); const remarkable = new Remarkable({ html: true, linkify: false });
const getValidImage = array => { const getValidImage = array => {
return array && return array && Array.isArray(array) && array.length >= 1 && typeof array[0] === 'string' ? array[0] : null;
Array.isArray(array) &&
array.length >= 1 &&
typeof array[0] === 'string'
? array[0]
: null;
}; };
export function extractRtags(body = null) { export function extractRtags(body = null) {
...@@ -22,12 +17,7 @@ export function extractRtags(body = null) { ...@@ -22,12 +17,7 @@ export function extractRtags(body = null) {
const isHtml = /^<html>([\S\s]*)<\/html>$/.test(body); const isHtml = /^<html>([\S\s]*)<\/html>$/.test(body);
const htmlText = isHtml const htmlText = isHtml
? body ? body
: remarkable.render( : remarkable.render(body.replace(/<!--([\s\S]+?)(-->|$)/g, '(html comment removed: $1)'));
body.replace(
/<!--([\s\S]+?)(-->|$)/g,
'(html comment removed: $1)'
)
);
rtags = HtmlReady(htmlText, { mutate: false }); rtags = HtmlReady(htmlText, { mutate: false });
} }
...@@ -84,12 +74,12 @@ export function extractBodySummary(body, stripQuotes = false) { ...@@ -84,12 +74,12 @@ export function extractBodySummary(body, stripQuotes = false) {
// Grab only the first line (not working as expected. does rendering/sanitizing strip newlines?) // Grab only the first line (not working as expected. does rendering/sanitizing strip newlines?)
desc = desc.trim().split('\n')[0]; desc = desc.trim().split('\n')[0];
if (desc.length > 140) { if (desc.length > 200) {
desc = desc.substring(0, 140).trim(); desc = desc.substring(0, 200).trim();
// Truncate, remove the last (likely partial) word (along with random punctuation), and add ellipses // Truncate, remove the last (likely partial) word (along with random punctuation), and add ellipses
desc = desc desc = desc
.substring(0, 120) .substring(0, 180)
.trim() .trim()
.replace(/[,!\?]?\s+[^\s]+$/, ''); .replace(/[,!\?]?\s+[^\s]+$/, '');
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment