How to use pageres - 5 common examples

To help you get started, we’ve selected a few pageres examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github visjs / vis-network / scripts / examples-index / generate.ts View on Github external
// it runs after the existing scripts on the page and therefore doesn't
    // allow to modify things prior to their invocation.
    const tmpPath = path.join(
      path.dirname(example.path),
      ".tmp.example.screenshot." + path.basename(example.path)
    );
    const screenshotPage = cheerio.load(example.html);
    screenshotPage("head").prepend(
      cheerio("
github javascriptair / site / other / screenshot-episode.js View on Github external
], ({url, episode}) => {
  const dest = path.resolve(userHome, 'Desktop')

  const urlToScreenshot = `${url}/?feature-show=${episode.date}`
  console.log(`Taking a screenshot of ${urlToScreenshot}`)
  new Pageres({delay: 2})
    .src(urlToScreenshot, ['1200x600'], {crop: true})
    .dest(dest)
    .run()
    .then(() => {
      console.log(`Screenshot saved: \n${dest}`)
    })
    .catch(err => {
      console.error(`Problems saving screenshot: \n${err}`)
    })
})
github anvilabs / anvilabs.co / gulpfile.babel.js View on Github external
glob.sync('public/blog/*/index.html').forEach((file: string) => {
    const pageres = new Pageres({
      crop: true,
      filename: 'post-screenshot',
      delay: 2,
      scale: 2,
      css: `
          .headroom-wrapper { display: none }
          #content { max-width: 48rem }
        `,
      format: 'jpg',
    });

    pageres
      .src(file, ['1200x630'])
      .dest(path.dirname(file))
      .run((err: ?Error) => {
        if (err) {
github javascriptair / site / generate / episode-screenshot.js View on Github external
function takeScreenshot(url, dest) {
  return new Pageres({filename: 'screenshot'})
    .src(url, ['1200x600'], {crop: true})
    .dest(dest)
    .run()
}
github bevacqua / shots / index.babel.js View on Github external
.then(chunks => chunks.reduce((p, chunk, i) => p.then(() => d(`reducing chunk ${i+1}/${chunks.length}, len=${chunk.length}`, chunk)
        .reduce((ctx, source) =>
          d(`adding pageres src ${source}, sizes=${sizes}`, ctx.src(source, sizes)),
          d('creating pageres instance', new Pageres(prOpts))
        )
        .dest(screenshots)
        .run()
        .then(streams => d(`renaming streams, len=${streams.length}`, Promise.all(
          streams.map(stream => d(`renaming ${stream.filename}`, prename(
            join(screenshots, stream.filename),
            join(screenshots, stream.filename
              .replace(`${pages.replace(rsep, '!')}!`, '')
              .replace(/\.html(-[\dx]+)[\w-]*\.png$/, '$1.html.png')
            )
          )))
        )))
      .catch(reason => d(`ERR! ${reason}`))
      ), d(`shot chunk reducer, len=${chunks.length}`, Promise.resolve())))

pageres

Capture website screenshots

MIT
Latest version published 4 months ago

Package Health Score

68 / 100
Full package analysis

Popular pageres functions