@tryghost/mg-assetscraper

0.4.16 • Public • Published

Migrate Assetscraper

Install

npm install @tryghost/mg-assetscraper --save

or

yarn add @tryghost/mg-assetscraper

Usage

// Default
const assetScraper = new AssetScraper(fileCache, {}, {
    logger: myLogger
});

// Later on, create the Listr tasks
const tasks = ctx.imageScraper.fetch(ctx);

// Create the Listr task runner, ensuring its not concurrent:
// Each task *must* be run sequentially
const taskRunner = makeTaskRunner(tasks, {concurrent: false});

// And later still, run those tasks
await taskRunner.run();

// `ctx` is now updated
// Set some options
// 2 MB maximum, and no media files
const assetScraper = new AssetScraper(fileCache, {
    sizeLimit: 2, // 2 MB
    allowMedia: false,
    baseDomain: 'https://example.com' // Set this domain to be added to relative asset links
}, {
    logger: myLogger
});

// Don't scrape assets from this URL
assetScraper.addBlockedDomain('https://my-custom-cdn.example.com');

// Now create & run tasks

Develop

This is a mono repository, managed with lerna.

Follow the instructions for the top-level repo.

  1. git clone this repo & cd into it as usual
  2. Run yarn to install top-level dependencies.

Run

  • yarn dev

Test

  • yarn lint run just eslint
  • yarn test run lint and tests
  • yarn benchmark run benchmarks

Copyright & License

Copyright (c) 2013-2023 Ghost Foundation - Released under the MIT license.

/@tryghost/mg-assetscraper/

    Package Sidebar

    Install

    npm i @tryghost/mg-assetscraper

    Weekly Downloads

    77

    Version

    0.4.16

    License

    MIT

    Unpacked Size

    45 kB

    Total Files

    6

    Last publish

    Collaborators

    • ryan_feigenbaum
    • erik-ghost
    • dvdwinden
    • vershwal
    • 9larsons
    • mike182uk
    • sagzy
    • chrisraible
    • jonhickman
    • kernalghost
    • hadret
    • minimaluminium
    • ronaldlangeveld
    • joeegrigg
    • sanne-san
    • djordjevlais
    • bobvaneck
    • zimoatghost
    • allouis
    • erisds
    • johnonolan
    • kevinansfield
    • cobbspur
    • aileencgn
    • jloh
    • daniellockyer
    • sam-lord
    • pauladamdavis