mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-16 02:27:21 +02:00
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:
parent
609e1b42e7
commit
18158d6abc
7 changed files with 123 additions and 60 deletions
|
@ -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,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue