Excerpt

Get the article description, or short excerpt from the content

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

const excerpt = microlink(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 result = await excerpt('https://developer.redis.com')

mql.render(result)