Skip to content

Commit 77f0053

Browse files
Merge pull request transitive-bullshit#387 from transitive-bullshit/feature/ky
2 parents 98fdc0f + d3d2390 commit 77f0053

File tree

3 files changed

+25
-22
lines changed

3 files changed

+25
-22
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@
2929
"@keyvhq/core": "^1.6.9",
3030
"@keyvhq/redis": "^1.6.10",
3131
"@react-icons/all-files": "^4.1.0",
32-
"@vercel/og": "^0.0.18",
32+
"@vercel/og": "^0.0.19",
3333
"classnames": "^2.3.1",
3434
"date-fns": "^2.28.0",
3535
"expiry-map": "^2.0.0",
3636
"fathom-client": "^3.4.1",
3737
"got": "^12.0.3",
3838
"isomorphic-unfetch": "^3.1.0",
39+
"ky": "^0.31.4",
3940
"lqip-modern": "^1.2.0",
4041
"next": "^12.3.1",
4142
"notion-client": "^6.13.11",

pages/api/social-image.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react'
22
import { NextRequest } from 'next/server'
33

44
import { ImageResponse } from '@vercel/og'
5+
import ky from 'ky'
56

67
import { api, apiHost } from '@/lib/config'
78
import { NotionPageInfo } from '@/lib/types'
@@ -30,15 +31,11 @@ export default async function OGImage(req: NextRequest) {
3031
return new Response('Invalid notion page id', { status: 400 })
3132
}
3233

33-
const pageInfoRes = await fetch(`${apiHost}${api.getNotionPageInfo}`, {
34-
method: 'POST',
35-
body: JSON.stringify({ pageId }),
36-
headers: { 'Content-Type': 'application/json' }
37-
})
38-
if (!pageInfoRes.ok) {
39-
return new Response(pageInfoRes.statusText, { status: pageInfoRes.status })
40-
}
41-
const pageInfo: NotionPageInfo = await pageInfoRes.json()
34+
const pageInfo = await ky
35+
.post(`${apiHost}${api.getNotionPageInfo}`, {
36+
json: { pageId }
37+
})
38+
.json<NotionPageInfo>()
4239
console.log(pageInfo)
4340

4441
return new ImageResponse(
@@ -86,7 +83,7 @@ export default async function OGImage(req: NextRequest) {
8683
style={{
8784
position: 'relative',
8885
width: 900,
89-
height: 450,
86+
height: 465,
9087
display: 'flex',
9188
flexDirection: 'column',
9289
border: '16px solid rgba(0,0,0,0.3)',
@@ -133,7 +130,7 @@ export default async function OGImage(req: NextRequest) {
133130
<div
134131
style={{
135132
position: 'absolute',
136-
top: 32,
133+
top: 47,
137134
left: 104,
138135
height: 128,
139136
width: 128,
@@ -157,7 +154,7 @@ export default async function OGImage(req: NextRequest) {
157154
),
158155
{
159156
width: 1200,
160-
height: 600,
157+
height: 630,
161158
fonts: [
162159
{
163160
name: 'Inter',

yarn.lock

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -675,13 +675,13 @@
675675
resolved "https://registry.npmjs.org/@use-it/event-listener/-/event-listener-0.1.7.tgz"
676676
integrity sha512-hgfExDzUU9uTRTPDCpw2s9jWTxcxmpJya3fK5ADpf5VDpSy8WYwY/kh28XE0tUcbsljeP8wfan48QvAQTSSa3Q==
677677

678-
"@vercel/og@^0.0.18":
679-
version "0.0.18"
680-
resolved "https://registry.yarnpkg.com/@vercel/og/-/og-0.0.18.tgz#4ee97eaf1f1fc2350447d3b43a1e4ee0c970de64"
681-
integrity sha512-cEid22FkiNrgJ/HtawA6V3+x2jhP+KqwwNG97afFsFmZ/oPsh3Bm01NzCVSpeR96/aPaT2/59pbFXGxulxgp7g==
678+
"@vercel/og@^0.0.19":
679+
version "0.0.19"
680+
resolved "https://registry.yarnpkg.com/@vercel/og/-/og-0.0.19.tgz#f0a796244c90b14aca40ee26225f2e046ccfda08"
681+
integrity sha512-1LrPUlCoe8T+aEI1fGdvJDhwewK1/wpYlQnF+E9ERgJMFCnmWH4FA+NYBkQaJqxUUeHoutIxNZTHQFT39+I+BQ==
682682
dependencies:
683683
"@resvg/resvg-wasm" "2.0.0-alpha.4"
684-
satori "0.0.40"
684+
satori "0.0.42"
685685
yoga-wasm-web "0.1.2"
686686

687687
"@xobotyi/scrollbar-width@^1.9.5":
@@ -2233,6 +2233,11 @@ keyv@^4.0.0:
22332233
compress-brotli "^1.3.6"
22342234
json-buffer "3.0.1"
22352235

2236+
ky@^0.31.4:
2237+
version "0.31.4"
2238+
resolved "https://registry.yarnpkg.com/ky/-/ky-0.31.4.tgz#c629a707053a92611cefa23079a0b0b60131b4b4"
2239+
integrity sha512-OFuAD3riwhAfHK3J4FrhlujFRpm0ELBEfDHZfFpw89OTozQt3NLF39lNblUO5udj5vSkyaBKnLai/rFCzBfISQ==
2240+
22362241
levn@^0.4.1:
22372242
version "0.4.1"
22382243
resolved "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz"
@@ -3278,10 +3283,10 @@ safe-regex-test@^1.0.0:
32783283
get-intrinsic "^1.1.3"
32793284
is-regex "^1.1.4"
32803285

3281-
3282-
version "0.0.40"
3283-
resolved "https://registry.yarnpkg.com/satori/-/satori-0.0.40.tgz#cc9c4b1c87820f4f62f90c9533d879cc74eb0194"
3284-
integrity sha512-SoXGq/89mBU34U1h4g/nXeL9DHS/Aof2iUL3FHabq+laSRQUSUI1ZhPhak3J6VMNW8wghYwJ/Bi7aF8FLPq9qQ==
3286+
3287+
version "0.0.42"
3288+
resolved "https://registry.yarnpkg.com/satori/-/satori-0.0.42.tgz#3cc4d7522e9264d1769a35f8da413811bb3b9752"
3289+
integrity sha512-ZZaNp2Ya1ACJ4Yf++e9Ccc1Rb6GcKjC9Nhcl4SQFcdM4VqCLfWHR6Iq7AdRCTcJDDuO8u/qGE2Cs+McVoqJenw==
32853290
dependencies:
32863291
"@shuding/opentype.js" "1.4.0-beta.0"
32873292
css-background-parser "^0.1.0"

0 commit comments

Comments
 (0)