Skip to content

Commit 150d6da

Browse files
committed
feat: add basic og api
1 parent e0a65c7 commit 150d6da

File tree

3 files changed

+330
-0
lines changed

3 files changed

+330
-0
lines changed

og/api/og.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { ImageResponse } from '@vercel/og';
2+
3+
export const config = {
4+
runtime: 'edge',
5+
};
6+
7+
export default function (_req: Request) {
8+
return new ImageResponse(
9+
{
10+
key: 'docs-page-og',
11+
type: 'div',
12+
props: {
13+
children: [
14+
{
15+
type: 'div',
16+
props: {
17+
style: {
18+
width: '80%',
19+
display: 'flex',
20+
flexDirection: 'column',
21+
textAlign: 'center',
22+
alignItems: 'center',
23+
},
24+
children: [
25+
{
26+
type: 'p',
27+
props: {
28+
style: { fontSize: 32 },
29+
children: 'Docs.Page',
30+
},
31+
},
32+
{
33+
type: 'p',
34+
props: {
35+
style: { fontSize: 64 },
36+
children: 'Title',
37+
},
38+
},
39+
],
40+
},
41+
},
42+
],
43+
style: {
44+
background: 'white',
45+
width: '100%',
46+
height: '100%',
47+
display: 'flex',
48+
textAlign: 'center',
49+
alignItems: 'center',
50+
justifyContent: 'center',
51+
flexDirection: 'column',
52+
backgroundImage:
53+
'radial-gradient(circle at 25px 25px, lightgray 2%, transparent 0%), radial-gradient(circle at 75px 75px, lightgray 2%, transparent 0%)',
54+
backgroundSize: '100px 100px',
55+
},
56+
},
57+
},
58+
{
59+
width: 1200,
60+
height: 600,
61+
},
62+
);
63+
}

og/package-lock.json

Lines changed: 254 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

og/package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "docs-page-og",
3+
"version": "1.0.0",
4+
"description": "OG Image generation API for docs.page",
5+
"scripts": {
6+
"test": "echo \"Error: no test specified\" && exit 1"
7+
},
8+
"author": "Invertase <[email protected]>",
9+
"license": "Apache-2.0",
10+
"dependencies": {
11+
"@vercel/og": "^0.0.21"
12+
}
13+
}

0 commit comments

Comments
 (0)