Skip to content
This repository has been archived by the owner on Jan 31, 2021. It is now read-only.

Commit

Permalink
social share preview dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
99littlebugs committed Jan 17, 2021
1 parent 0ddc271 commit 58158db
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ node_modules/

# should be generated
site/index.html
site/images/social-share.png
14 changes: 14 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const handlebars = require('handlebars');
const fs = require("fs");
const path = require('path');
const puppeteer = require('puppeteer');

handlebars.registerHelper('date', function (date) {
const options = { weekday: 'short', month: 'short', day: 'numeric' };
Expand All @@ -26,6 +27,19 @@ for (const site of data.sites) {

fs.writeFileSync(path.join("site", "index.html"), template({ sites: sites.sort(sortByProperty("name")), events: events.sort(sortByProperty("date")) }));

(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({
width: 1200,
height: 628,
deviceScaleFactor: 1
});
await page.goto(`file://${path.join(__dirname, "site", "index.html")}`);
await page.screenshot({path: path.join("site", "images", "social-share.png")});
await browser.close();
})();

function sortByProperty(property) {
return function (a, b) {
if (a[property] > b[property])
Expand Down
Binary file removed site/images/vaccine-site-finder.png
Binary file not shown.
2 changes: 1 addition & 1 deletion site/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Font -->
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">

<!-- CSS -->
<link rel="stylesheet" href="css/normalize.css">
Expand Down

0 comments on commit 58158db

Please sign in to comment.