-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathogp.ts
61 lines (58 loc) · 1.24 KB
/
ogp.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import satori from "satori"
import { Resvg } from "@resvg/resvg-js"
export async function generateOgp({
text,
font,
}: //vertical,
{
text: string
font: Buffer
//vertical: boolean
}) {
const svg = await satori(
{
type: "div",
props: {
style: {
display: "flex",
justifyContent: "center",
alignItems: "center",
textAlign: "left",
width: 1200,
height: 630,
background: "linear-gradient(90deg, #e6e6e6 50%, #f2f2f2 50%)",
},
children: {
type: "div",
props: {
style: {
display: "flex",
justifyContent: "center",
alignItems: "center",
width: 1040,
height: 390,
fontSize: "60px",
color: "#333333",
//writingMode: vertical ? "vertical-rl" : "inherit",
},
children: text,
},
},
},
} as any,
{
width: 1200,
height: 630,
fonts: [
{
name: "MergedYakuhanJP",
data: font,
weight: 900,
style: "normal",
},
],
}
)
const resvg = new Resvg(svg)
return resvg.render().asPng()
}