yoastseo
Version:
Yoast client-side content analysis
28 lines (26 loc) • 986 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
/**
* @typedef {import("../../../parse/structure").Node} Node
* @typedef {import("../../../parse/structure/Sentence").default} Sentence
*/
/**
* Gets all the sentences from paragraph and heading nodes.
* These two node types are the nodes that should contain sentences for the analysis.
*
* @param {Node} tree The tree to get the sentences from.
*
* @returns {Sentence[]} The array of sentences retrieved from paragraph and heading nodes plus sourceCodeLocation of the parent node.
*/
function _default(tree) {
// Get all nodes that have a sentence property which is not an empty array.
const nodesWithSentences = tree.findAll(treeNode => !!treeNode.sentences);
return nodesWithSentences.flatMap(node => node.sentences.map(sentence => {
sentence.setParentAttributes(node, tree);
return sentence;
}));
}
//# sourceMappingURL=getSentencesFromTree.js.map