Skip to content

Commit 4dda6af

Browse files
authored
chore(docs): add default og:image (#10777)
1 parent 5e55331 commit 4dda6af

File tree

17 files changed

+187
-20
lines changed

17 files changed

+187
-20
lines changed

docs/app/api/og/Inter-Black.ttf

287 KB
Binary file not shown.

docs/app/api/og/Inter-Bold.ttf

287 KB
Binary file not shown.

docs/app/api/og/Inter-Light.ttf

281 KB
Binary file not shown.

docs/app/api/og/route.tsx

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
import { ImageResponse } from "next/og"
2+
import { type NextRequest } from "next/server"
3+
4+
export const runtime = "edge"
5+
6+
const medium = fetch(new URL("./Inter-Light.ttf", import.meta.url)).then(
7+
(res) => res.arrayBuffer()
8+
)
9+
10+
const bold = fetch(new URL("./Inter-Bold.ttf", import.meta.url)).then((res) =>
11+
res.arrayBuffer()
12+
)
13+
14+
const foreground = "hsl(0 0% 98%)"
15+
const mutedForeground = "hsl(0 0% 53.9%)"
16+
const background = "rgba(10, 10, 10, 0.90)"
17+
18+
export async function GET(request: NextRequest) {
19+
const { searchParams } = new URL(request.url!)
20+
const title = searchParams.get("title")
21+
const description = searchParams.get("description")
22+
23+
var url = `data:image/svg+xml;base64,${btoa(backgroundSvg)}`
24+
25+
return new ImageResponse(
26+
OG({
27+
title: title ?? "Authentication for the Web.",
28+
description: description ?? "",
29+
bgSvg: url,
30+
}),
31+
{
32+
width: 1200,
33+
height: 630,
34+
fonts: [
35+
{ name: "Inter", data: await medium, weight: 300 },
36+
{ name: "Inter", data: await bold, weight: 800 },
37+
],
38+
}
39+
)
40+
}
41+
42+
function OG({
43+
title,
44+
description,
45+
bgSvg,
46+
}: {
47+
bgSvg: string
48+
title: string
49+
description: string
50+
}) {
51+
return (
52+
<div
53+
tw="flex flex-col w-full h-full pb-12 pt-16 px-16"
54+
style={{
55+
fontFamily: "'Inter', system-ui, sans-serif",
56+
color: foreground,
57+
backgroundSize: "1200 630",
58+
}}
59+
>
60+
<img
61+
tw="absolute top-0 left-0"
62+
style={{ width: 1200, height: 660 }}
63+
src={bgSvg}
64+
></img>
65+
<div
66+
tw="flex flex-col justify-center rounded-2xl p-3 shadow-2xl"
67+
style={{
68+
background:
69+
"linear-gradient(to right bottom, rgb(40, 158, 249), rgb(91, 33, 182))",
70+
// New colors: "linear-gradient(to right bottom, rgb(255, 68, 0), rgb(187, 68, 204))",
71+
}}
72+
>
73+
<div
74+
tw="flex flex-col items-center rounded-xl p-12"
75+
style={{
76+
border: "1px rgba(156,163,175,0.3)",
77+
background,
78+
}}
79+
>
80+
<p
81+
style={{
82+
fontSize: "3.5rem",
83+
fontWeight: 300,
84+
maxHeight: "14rem",
85+
overflow: "hidden",
86+
textAlign: "center",
87+
textWrap: "balance",
88+
}}
89+
>
90+
{title}
91+
</p>
92+
</div>
93+
</div>
94+
95+
<div tw="flex flex-row items-center justify-between mt-auto p-4">
96+
<div tw="flex">
97+
<img
98+
src="https://authjs.dev/img/logo-sm.png"
99+
width={77}
100+
height={90}
101+
/>
102+
<p
103+
style={{
104+
fontWeight: 800,
105+
marginLeft: "1rem",
106+
fontSize: "2.3rem",
107+
}}
108+
>
109+
Auth.js
110+
</p>
111+
</div>
112+
<p
113+
style={{
114+
marginLeft: "3rem",
115+
color: mutedForeground,
116+
fontWeight: 300,
117+
fontSize: "2rem",
118+
}}
119+
>
120+
{description}
121+
</p>
122+
</div>
123+
</div>
124+
)
125+
}
126+
127+
const backgroundSvg = `
128+
<svg width="2560" height="1280" viewBox="0 0 2560 1280" fill="none" xmlns="http://www.w3.org/2000/svg">
129+
<g clip-path="url(#clip0_511_47)">
130+
<rect width="2560" height="1280" fill="#111111"/>
131+
<path d="M438.668 1160.38C1283.52 617.831 3403.85 1713.01 2144.14 1267.27L1980.48 1809.63C1746.84 1726.27 1275.31 1558.8 1258.29 1555.83C1237 1552.12 -35.3605 1436.43 151.807 1269.12C242.949 1225.11 254.011 1278.96 438.668 1160.38Z" fill="url(#paint0_radial_511_47)"/>
132+
<path d="M2335.05 977.4C1638.8 708.04 1258.25 143.506 1155 -105.091L2257.61 -196C2573.53 307.367 3031.29 1246.76 2335.05 977.4Z" fill="url(#paint1_radial_511_47)"/>
133+
<path d="M888.078 42.3028C465.467 1294.94 73.8505 662.761 -266.668 854.807L-294.52 -12.0731C-119.086 -25.2806 234.782 -53.0437 246.789 -58.4363C261.797 -65.1771 1132.31 -620.045 1050.51 -275.273C1001.27 -160.866 980.447 -231.483 888.078 42.3028Z" fill="url(#paint2_radial_511_47)"/>
134+
</g>
135+
<defs>
136+
<radialGradient id="paint0_radial_511_47" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(1016.5 939) rotate(93.0267) scale(757.557 879.417)">
137+
<stop stop-color="#FF7722"/>
138+
<stop offset="1" stop-color="#111111"/>
139+
</radialGradient>
140+
<radialGradient id="paint1_radial_511_47" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(1653 619) rotate(-46.5881) scale(548.572 1194.34)">
141+
<stop stop-color="#BB44CC"/>
142+
<stop offset="1" stop-color="#111111"/>
143+
</radialGradient>
144+
<radialGradient id="paint2_radial_511_47" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(666.999 571.116) rotate(-129.513) scale(513.947 862.777)">
145+
<stop stop-color="rgb(40, 158, 249)"/>
146+
<stop offset="1" stop-color="#111111"/>
147+
</radialGradient>
148+
<clipPath id="clip0_511_47">
149+
<rect width="2560" height="1280" fill="white"/>
150+
</clipPath>
151+
</defs>
152+
</svg>
153+
`
154+
155+
// New colors - '#44BBCC', '#BB44CC', '#FF4400'
File renamed without changes.
File renamed without changes.

docs/components/Docsearch/wrapper.tsx renamed to docs/components/DocSearch/wrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { CustomSearchBox } from "./searchInput"
66
import Hit from "./hit"
77

88
const algoliaClient = algoliasearch(
9-
process.env.NEXT_PUBLIC_ALGOLIA_APP_ID,
10-
process.env.NEXT_PUBLIC_ALGOLIA_KEY
9+
process.env.NEXT_PUBLIC_ALGOLIA_APP_ID!,
10+
process.env.NEXT_PUBLIC_ALGOLIA_KEY!
1111
)
1212

1313
const searchClient = {

docs/components/Footer/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function Footer({ className = "" }) {
1313
fetch("https://api.github.com/repos/nextauthjs/next-auth")
1414
.then((res) => res.json())
1515
.then((data) => {
16-
const githubStat = document.querySelector(".github-counter")
16+
const githubStat = document.querySelector(".github-counter")!
1717
githubStat.innerHTML = kFormatter(data.stargazers_count ?? 21100)
1818
})
1919

docs/components/LogosMarquee/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const LogosMarquee = memo(() => {
4949
>
5050
{Object.entries(manifest.providersOAuth)
5151
.sort(() => Math.random() - 0.5)
52-
.filter((_, i) => i < logoCount)
52+
.filter((_, i) => i < logoCount!)
5353
.map(([key, name]) => (
5454
<Motion
5555
key={`company-${key}`}
@@ -61,7 +61,7 @@ export const LogosMarquee = memo(() => {
6161
initDeg={randomIntFromInterval(0, 360)}
6262
direction={Math.random() > 0.5 ? "clockwise" : "counterclockwise"}
6363
velocity={10}
64-
radius={scale}
64+
radius={scale!}
6565
>
6666
<Img
6767
src={`/img/providers/${key}.svg`}

0 commit comments

Comments
 (0)