UNPKG

yoastseo

Version:

Yoast client-side content analysis

37 lines (36 loc) 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getFieldsToMark = getFieldsToMark; var _lodash = require("lodash"); var _getSubheadings = require("./getSubheadings"); /** * Gets the part of the html that we want to apply the marking to. * * @param {array} marks The array of mark objects. * @param {string} html The html of the page where we want to apply the marking to. * * @returns {{selectedHTML: *[], fieldsToMark: *}} The selected part of the html we want to apply the marking to. */ function getFieldsToMark(marks, html) { const fieldsToMark = (0, _lodash.uniq)((0, _lodash.flatten)(marks.map(mark => { if (!(0, _lodash.isUndefined)(mark.getFieldsToMark())) { return mark.getFieldsToMark(); } }))); const selectedHTML = []; fieldsToMark.forEach(field => { if (field === "heading") { const subheadings = (0, _getSubheadings.getSubheadings)(html); subheadings.forEach(subheading => { selectedHTML.push(subheading[0]); }); } }); return { fieldsToMark, selectedHTML }; } //# sourceMappingURL=getFieldsToMark.js.map