Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit 0a2741e

Browse files
added some comments to create-excerpt hook
1 parent f0c46c8 commit 0a2741e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/hooks/create-excerpt.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ module.exports = function (options = {}) { // eslint-disable-line no-unused-vars
3333
.replace(/(\ ){2,}/ig, ' ')
3434
.trim();
3535

36-
contentBefore = trunc(content, 9999999999);
36+
// we do need to compare the strings to decide if we really need to trim
37+
const contentBefore = trunc(content, 9999999999);
3738
const contentTruncated = trunc(contentSanitized, options.length);
3839
hook.app.debug('contentBefore');
3940
hook.app.debug(contentBefore.text.length);
4041
hook.app.debug('contentTruncated');
4142
hook.app.debug(contentTruncated.text.length);
4243

44+
// save meta key hasMore to indecate if there is more text then in the excerpt
4345
const hasMore = contentBefore.text.length > (contentTruncated.text.length + 20);
4446
setByDot(hook.data, 'hasMore', hasMore);
4547

0 commit comments

Comments
 (0)