Excerpt

Get the article description, or short excerpt from the content

excerpt.js
const mql = require('@microlink/mql')

const code = async ({ url, html }) => {
  const { Readability } = require('@mozilla/readability')
  const { JSDOM, VirtualConsole } = require('jsdom')

  const dom = new JSDOM(html, {
    url,
    virtualConsole: new VirtualConsole()
  })

  const reader = new Readability(dom.window.document)
  return reader.parse().excerpt
}

const excerpt = (url, props) =>
  mql(url, { function: code.toString(), meta: false, ...props }).then(
    ({ data }) => data.function
  )

const result = await excerpt('https://developer.redis.com')

mql.render(result)