Skip to content

Commit

Permalink
fix(web): og image
Browse files Browse the repository at this point in the history
  • Loading branch information
tszhong0411 committed Dec 15, 2024
1 parent 37b9008 commit 592a0b7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions apps/web/src/app/og/[id]/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { getErrorMessage } from '@tszhong0411/utils'
import { allBlogPosts } from 'mdx/generated'
import { ImageResponse } from 'next/og'
import { NextResponse } from 'next/server'
import { readFileSync } from 'node:fs'
import path from 'node:path'

import { SITE_URL } from '@/lib/constants'

Expand All @@ -12,6 +14,10 @@ type OGRouteProps = {
}>
}

export const loadFile = (filePath: string): Buffer => {
return readFileSync(path.join(process.cwd(), filePath))
}

export const GET = async (_: Request, props: OGRouteProps) => {
try {
const { id } = await props.params
Expand All @@ -36,9 +42,7 @@ export const GET = async (_: Request, props: OGRouteProps) => {
return 64
}

const roboto = await fetch(
new URL('../../../../public/fonts/RobotoCondensed-Bold.ttf', import.meta.url)
).then((res) => res.arrayBuffer())
const roboto = loadFile('public/fonts/RobotoCondensed-Bold.ttf')

const post = await db
.select({
Expand Down

0 comments on commit 592a0b7

Please sign in to comment.