mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-03 19:11:22 +01:00
feat: add a '[...]' to the end of the generated summary when federating out articles (fep-b2b8)
This commit is contained in:
@@ -759,7 +759,12 @@ Mocks.notes.public = async (post) => {
|
|||||||
// Append sentences to summary until it contains just under 500 characters of content
|
// Append sentences to summary until it contains just under 500 characters of content
|
||||||
const limit = 500;
|
const limit = 500;
|
||||||
let remaining = limit;
|
let remaining = limit;
|
||||||
|
let finished = false;
|
||||||
summary = sentences.reduce((memo, sentence) => {
|
summary = sentences.reduce((memo, sentence) => {
|
||||||
|
if (finished) {
|
||||||
|
return memo;
|
||||||
|
}
|
||||||
|
|
||||||
const clean = sanitize(sentence, {
|
const clean = sanitize(sentence, {
|
||||||
allowedTags: [],
|
allowedTags: [],
|
||||||
allowedAttributes: {},
|
allowedAttributes: {},
|
||||||
@@ -767,6 +772,9 @@ Mocks.notes.public = async (post) => {
|
|||||||
remaining = remaining - clean.length;
|
remaining = remaining - clean.length;
|
||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
memo += ` ${sentence}`;
|
memo += ` ${sentence}`;
|
||||||
|
} else { // There was more but summary generation is complete
|
||||||
|
finished = true;
|
||||||
|
memo += ' [...]';
|
||||||
}
|
}
|
||||||
|
|
||||||
return memo;
|
return memo;
|
||||||
|
|||||||
Reference in New Issue
Block a user