fix: truncate blogpost properly with truncate-html (#880)

* fix: truncate blogpost properly with truncate-html

* revert test file change

* chore: truncate blogpost for feed changelog
This commit is contained in:
Endilie Yacop Sucipto 2018-08-02 15:16:26 +08:00 committed by GitHub
parent 609e1b42e7
commit 18158d6abc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 123 additions and 60 deletions

View file

@ -5,7 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/
const BLOG_POST_SUMMARY_LENGTH = 250;
const TRUNCATE_MARKER = /<!--\s*truncate\s*-->/;
function blogPostHasTruncateMarker(content) {
@ -16,10 +15,6 @@ function extractBlogPostBeforeTruncate(content) {
return content.split(TRUNCATE_MARKER)[0];
}
function extractBlogPostSummary(content) {
return content.substring(0, BLOG_POST_SUMMARY_LENGTH);
}
function removeExtension(path) {
return path.replace(/\.[^/.]+$/, '');
}
@ -36,7 +31,6 @@ function getPath(path, cleanUrl = false) {
module.exports = {
blogPostHasTruncateMarker,
extractBlogPostBeforeTruncate,
extractBlogPostSummary,
getPath,
removeExtension,
};