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 ({ query, html }) => {
  const { Readability } = require('@mozilla/readability')
  const { JSDOM, VirtualConsole } = require('jsdom')

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

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

const result = await excerpt('https://fithero.app')

mql.render(result)