Skip to content

Commit

Permalink
Switch canvas logic to puppeteer screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
ashley-hebler committed Jan 31, 2021
1 parent f435558 commit 2eef08a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 78 deletions.
78 changes: 0 additions & 78 deletions docs/config/tasks/date-label.ts

This file was deleted.

26 changes: 26 additions & 0 deletions docs/config/tasks/date-labels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const ora = require('ora');
const puppeteer = require('puppeteer');
const path = require('path');
const { docsImages } = require('../paths');
const { years } = require('./utils');

module.exports = async () => {
const spinner = ora('Generating date labels').start();
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('http://localhost:8080/date-labels/');
await page.waitForSelector('.date-labels');
const elements = await page.$$('.date-label');
const yearObj = { ...years() };
// eslint-disable-next-line no-plusplus
for (let i = 0; i < elements.length; i++) {
// eslint-disable-next-line no-await-in-loop
await elements[i].screenshot({
path: `${path.join(docsImages, 'date-labels', '/')}${yearObj[i]}.png`,
});
}

await browser.close();

spinner.succeed();
};

0 comments on commit 2eef08a

Please sign in to comment.