Ghost/core/server/services/mega/segment-parser.js

14 lines
364 B
JavaScript
Raw Normal View History

const getSegmentsFromHtml = (html) => {
const cheerio = require('cheerio');
const $ = cheerio.load(html);
const allSegments = $('[data-gh-segment]')
.get()
.map(el => el.attribs['data-gh-segment']);
// only return unique elements
return [...new Set(allSegments)];
};
module.exports.getSegmentsFromHtml = getSegmentsFromHtml;