Skip to content

Commit

Permalink
reducing size of previews to 140 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
RmnRss committed Aug 12, 2020
1 parent 43a765a commit b2b7997
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions api/api/article/config/functions/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ module.exports = {
// Searching for urls in the content.
const imgUrls = Array.from(
tempContent.matchAll(/!\[(.*?)\]\((.*?)\)/g),
(m) => ({ alt: m[1], url: m[2] })
m => ({ alt: m[1], url: m[2] })
);

const urls = Array.from(
tempContent.matchAll(/\[(.*?)\]\((.*?)\)/g),
(m) => ({ alt: m[1], url: m[2] })
);
const urls = Array.from(tempContent.matchAll(/\[(.*?)\]\((.*?)\)/g), m => ({
alt: m[1],
url: m[2]
}));

const allUrls = urls.concat(imgUrls);

Expand All @@ -30,13 +30,13 @@ module.exports = {
tempContent = tempContent.replace(link, obj.alt);
}

data.preview = tempContent.substring(0, 416) + "...";
data.preview = tempContent.substring(0, 136) + "...";
},

/***
* update the preview of an existing article
*/
async updatePreview(params, data) {
this.addPreview(data);
},
}
};
2 changes: 1 addition & 1 deletion api/api/article/models/article.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"preview": {
"type": "text",
"required": false,
"maxLength": 420,
"maxLength": 140,
"minLength": 1
},
"categories": {
Expand Down

0 comments on commit b2b7997

Please sign in to comment.