`npm install @tryghost/mg-assetscraper --save`
npm install @tryghost/mg-assetscrapernpm install @tryghost/mg-assetscraper --save
or
yarn add @tryghost/mg-assetscraper
``js
// 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`
`js
// 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
`
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 usualyarn
2. Run to install top-level dependencies.
- yarn dev
- yarn lint run just eslintyarn test
- run lint and testsyarn benchmark` run benchmarks
-
Copyright (c) 2013-2026 Ghost Foundation - Released under the MIT license.