-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ab38cf9
Showing
9 changed files
with
442 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
dist | ||
LICENSE |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 ZEIT, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# OG Image | ||
|
||
To run locally: | ||
|
||
- `now dev` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "generate-og-image", | ||
"version": 2, | ||
"public": false, | ||
"builds": [ | ||
{ | ||
"src": "src/card.ts", | ||
"use": "@now/node", | ||
"config": { "maxLambdaSize": "36mb" } | ||
} | ||
], | ||
"routes": [{ "src": "/og.jpg", "dest": "/src/card.ts" }] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "generating-og-image", | ||
"version": "1.0.0", | ||
"description": "Generate an OG Image", | ||
"main": "dist/card.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"now-build": "tsc", | ||
"watch": "tsc --watch" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"chrome-aws-lambda": "1.18.1", | ||
"puppeteer-core": "1.18.1" | ||
}, | ||
"devDependencies": { | ||
"@types/puppeteer-core": "1.9.0", | ||
"typescript": "3.5.3" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { IncomingMessage, ServerResponse } from "http"; | ||
|
||
export default async function handler( | ||
_req: IncomingMessage, | ||
res: ServerResponse | ||
) { | ||
try { | ||
const html = ` | ||
<!DOCTYPE html> | ||
<html> | ||
<meta charset="utf-8"> | ||
<title>Generated Image</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link href="https://fonts.googleapis.com/css?family=Barlow+Condensed&display=swap" rel="stylesheet"> | ||
<style> | ||
body { | ||
background: yellow; | ||
} | ||
</style> | ||
<body> | ||
<div class="container"> | ||
<div class="title">Generating OG Images</div> | ||
<div class="author"> | ||
<img src="https://flipgive.imgix.net/images/users/avatars/000/000/010/original/1532032692llamas-and-haircuts-llama-justin-bieber.jpg" class="author-image" /> | ||
Leigh Halliday | ||
</div> | ||
<div class="website">leighhalliday.com</div> | ||
</div> | ||
</body> | ||
</html> | ||
`; | ||
|
||
res.statusCode = 200; | ||
res.setHeader("Content-Type", "text/html"); | ||
res.end(html); | ||
} catch (e) { | ||
res.statusCode = 500; | ||
res.setHeader("Content-Type", "text/html"); | ||
res.end("<h1>Internal Error</h1><p>Sorry, an error occurred.</p>"); | ||
console.error(e); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"module": "commonjs", | ||
"target": "esnext", | ||
"moduleResolution": "node", | ||
"jsx": "react", | ||
"sourceMap": true, | ||
"strict": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitReturns": true, | ||
"noEmitOnError": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"removeComments": true, | ||
"preserveConstEnums": true, | ||
"esModuleInterop": true | ||
}, | ||
"exclude": ["node_modules"] | ||
} |
Oops, something went wrong.
ab38cf9
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully aliased the URL https://generate-og-image-n65lrtqcv.now.sh to the following aliases: