diff --git a/gulpfile.js b/gulpfile.js index 94121fc7..436a2573 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -126,7 +126,7 @@ exports.dropContent = () => del(['content', ...contentRepFolders.map((folder) => // Social cards const socialCards = async () => { - const browser = await puppeteer.launch({ headless: true }) + const browser = await puppeteer.launch({ headless: 'new' }) const page = await browser.newPage() return pipeline( @@ -135,10 +135,19 @@ const socialCards = async () => { objectMode: true, async transform(file, encoding, done) { const imagePath = file.path.replace('index.sc.html', 'images/covers/') - await fsp.mkdir(imagePath, { recursive: true }) + if (!fs.existsSync(imagePath)) { + await fsp.mkdir(imagePath, { recursive: true }) + } await page.goto('file://' + file.path) + await page.evaluate(() => { + const image = document.querySelector('.social-card__image') + if (image) { + image.setAttribute('src', image.src.replace(/.*images\//, 'images/')) + } + }) + await page.setViewport({ width: 503, height: 273,