Created
April 27, 2016 13:09
-
-
Save tmcw/b1648141d7ae712a544e3ffe926e25d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Script that gets a screenshot of every file linked in a Markdown file | |
*/ | |
var fs = require('fs'); | |
var visit = require('unist-util-visit'); | |
var Pageres = require('pageres'); | |
var remark = require('remark'); | |
var ast = remark.parse(fs.readFileSync('DOCS.md', 'utf8')); | |
var urls = []; | |
visit(ast, 'link', function(link) { | |
urls.push(link.url); | |
}); | |
const pageres = new Pageres({delay: 2}) | |
.dest('output'); | |
pageres = urls | |
.filter(url => !url.match(/twitter/)) | |
.reduce((memo, url) => pageres.src(url, ['1280x1024']), pageres); | |
pageres.on('warn', err => console.error(err)); | |
pageres.run() | |
.then(() => console.log('done')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment