-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
[...path].ts
68 lines (60 loc) · 1.68 KB
/
[...path].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
62
63
64
65
66
67
68
import { getCollection } from "astro:content";
import { OGImageRoute } from "astro-og-canvas";
const collectionEntries = await getCollection("docs");
/** Paths for all of our Markdown content we want to generate OG images for. */
const pages = process.env.SKIP_OG
? []
: Object.fromEntries(collectionEntries.map(({ slug, data }) => [slug, data]));
export const { getStaticPaths, GET } = OGImageRoute({
param: "path",
pages,
getImageOptions: (_, page) => {
return {
title: page.title,
description: page.description,
logo: {
path: "./public/img/logo-avatar.png",
size: [200],
},
bgImage: {
path: "./src/assets/bg.png",
fit: "cover",
},
font: {
title: {
size: 72,
lineHeight: 1.2,
families: [
"Obviously",
"Inter",
"Noto Sans",
"Noto Sans Arabic",
"Noto Sans SC",
"Noto Sans TC",
"Noto Sans JP",
"Noto Sans KR",
],
weight: "Medium",
color: [255, 255, 255],
},
description: {
size: 42,
lineHeight: 1.2,
families: ["Inter", "Noto Sans", "Noto Sans SC", "Noto Sans JP"],
weight: "Normal",
color: [255, 255, 255],
},
},
fonts: [
"./src/pages/og/_fonts/inter/inter-400-normal.ttf",
"./src/pages/og/_fonts/inter/inter-500-normal.ttf",
"./src/pages/og/_fonts/noto-sans/noto-400-normal.ttf",
"./src/pages/og/_fonts/noto-sans/noto-500-normal.ttf",
"./src/pages/og/_fonts/noto-sans/chinese-simplified-400-normal.otf",
"./src/pages/og/_fonts/noto-sans/chinese-simplified-500-normal.ttf",
"./src/pages/og/_fonts/noto-sans/japanese-400-normal.ttf",
"./src/pages/og/_fonts/noto-sans/japanese-500-normal.ttf",
],
};
},
});