Text

Get the text content of the target URL

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

const code = async ({ url, html }) => {
  const condenseWhitespace = require('condense-whitespace')
  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)
  const { textContent } = reader.parse()
  return condenseWhitespace(textContent)
}

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

const result = await text('https://geohot.github.io/blog/jekyll/update/2023/04/26/a-person-of-compute.html')

mql.render(result)