url-metadata
Version:
Request a url and scrape the metadata from its HTML using Node.js or the browser.
17 lines (13 loc) • 336 B
JavaScript
const utils = require('./utils')
module.exports = function ($) {
const $headings = $('h1, h2, h3, h4, h5, h6')
const extracted = []
$headings.each(function (index, el) {
const heading = {
level: el.name,
text: utils.stripNewlines($(el).text().trim())
}
extracted.push(heading)
})
return extracted
}