Skip to content

v9.0.0 - Deno/JSR first

Choose a tag to compare

@ndaidong ndaidong released this 06 Aug 12:23
· 8 commits to main since this release
68fa294
  • Rewrite in TypeScript, with Deno/JSR as primary target
  • Allow consumer to custom fetcher (replace old fetchOptions)
  • Simplify html sanitizing with built-in function (remove sanitize-html dependency and related config methods)
  • Fix JSON-LD logic (#425)

Breaking changes

Use custom fetcher instead of fetchOptions

Before v9.0.0:

import { extract } from '@extractus/article-extractor'

const url = 'https://example.com/some-article'
const article = await extract(url, {}, {
  headers: {
    'user-agent': 'Opera/9.60 (Windows NT 6.0; U; en) Presto/2.1.1'
  }
})

Since v9.0.0:

const myFetcher = (url: string) =>
  fetch(url, {
    headers: {
      "user-agent": "Opera/9.60 (Windows NT 6.0; U; en) Presto/2.1.1",
    },
  });

const article = await extract("https://example.com/some-article", {}, myFetcher);

Configure content sanitizing via parserOptions

Before v9.0.0:

import { setSanitizeHtmlOptions } from '@extractus/article-extractor'

setSanitizeHtmlOptions({
  allowedAttributes: {
    a: ["href", "target", "title"],
    img: ["src", "srcset", "alt", "title"],
    code: ["class"],
    div: ["class"],
  },
})

Since v9.0.0:

import { extract } from "jsr:@extractus/article-extractor";

const article = await extract(url, {
  allowedAttributes: {
    a: ["href", "target", "title"],
    img: ["src", "srcset", "alt", "title"],
    code: ["class"],
    div: ["class"],
  },
});

Check README for more detail.