mirror of
https://github.com/d0zingcat/nextjs-notion-starter-kit.git
synced 2026-05-13 15:09:47 +00:00
feat: use ky instead of fetch for edge func
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
"fathom-client": "^3.4.1",
|
||||
"got": "^12.0.3",
|
||||
"isomorphic-unfetch": "^3.1.0",
|
||||
"ky": "^0.31.4",
|
||||
"lqip-modern": "^1.2.0",
|
||||
"next": "^12.3.1",
|
||||
"notion-client": "^6.13.11",
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as React from 'react'
|
||||
import { NextRequest } from 'next/server'
|
||||
|
||||
import { ImageResponse } from '@vercel/og'
|
||||
import ky from 'ky'
|
||||
|
||||
import { api, apiHost } from '@/lib/config'
|
||||
import { NotionPageInfo } from '@/lib/types'
|
||||
@@ -30,15 +31,11 @@ export default async function OGImage(req: NextRequest) {
|
||||
return new Response('Invalid notion page id', { status: 400 })
|
||||
}
|
||||
|
||||
const pageInfoRes = await fetch(`${apiHost}${api.getNotionPageInfo}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ pageId }),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
if (!pageInfoRes.ok) {
|
||||
return new Response(pageInfoRes.statusText, { status: pageInfoRes.status })
|
||||
}
|
||||
const pageInfo: NotionPageInfo = await pageInfoRes.json()
|
||||
const pageInfo = await ky
|
||||
.post(`${apiHost}${api.getNotionPageInfo}`, {
|
||||
json: { pageId }
|
||||
})
|
||||
.json<NotionPageInfo>()
|
||||
console.log(pageInfo)
|
||||
|
||||
return new ImageResponse(
|
||||
@@ -86,7 +83,7 @@ export default async function OGImage(req: NextRequest) {
|
||||
style={{
|
||||
position: 'relative',
|
||||
width: 900,
|
||||
height: 450,
|
||||
height: 465,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
border: '16px solid rgba(0,0,0,0.3)',
|
||||
@@ -133,7 +130,7 @@ export default async function OGImage(req: NextRequest) {
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: 32,
|
||||
top: 47,
|
||||
left: 104,
|
||||
height: 128,
|
||||
width: 128,
|
||||
@@ -157,7 +154,7 @@ export default async function OGImage(req: NextRequest) {
|
||||
),
|
||||
{
|
||||
width: 1200,
|
||||
height: 600,
|
||||
height: 630,
|
||||
fonts: [
|
||||
{
|
||||
name: 'Inter',
|
||||
|
||||
@@ -2233,6 +2233,11 @@ keyv@^4.0.0:
|
||||
compress-brotli "^1.3.6"
|
||||
json-buffer "3.0.1"
|
||||
|
||||
ky@^0.31.4:
|
||||
version "0.31.4"
|
||||
resolved "https://registry.yarnpkg.com/ky/-/ky-0.31.4.tgz#c629a707053a92611cefa23079a0b0b60131b4b4"
|
||||
integrity sha512-OFuAD3riwhAfHK3J4FrhlujFRpm0ELBEfDHZfFpw89OTozQt3NLF39lNblUO5udj5vSkyaBKnLai/rFCzBfISQ==
|
||||
|
||||
levn@^0.4.1:
|
||||
version "0.4.1"
|
||||
resolved "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz"
|
||||
|
||||
Reference in New Issue
Block a user