-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: simple og image * feat: simple og image * fix: redirect to thread landing on homepage * fix: link to terms
- Loading branch information
1 parent
b8df4fb
commit 9a6c866
Showing
11 changed files
with
129 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { ImageResponse } from '@vercel/og' | ||
import { NextRequest } from 'next/server' | ||
import { GeistMono } from 'geist/font/mono' // Import the GeistMono font | ||
|
||
export const runtime = 'edge' | ||
|
||
export async function GET(req: NextRequest) { | ||
const { searchParams } = req.nextUrl | ||
const postTitle = searchParams.get('title') | ||
|
||
// You may need to convert GeistMono or fetch it as ArrayBuffer if needed | ||
// const font = GeistMono; // Assuming GeistMono can be directly used, modify as needed | ||
|
||
return new ImageResponse( | ||
( | ||
<div | ||
style={{ | ||
height: '100%', | ||
width: '100%', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'flex-start', | ||
justifyContent: 'center', | ||
background: '#110f0f' | ||
}} | ||
> | ||
<div | ||
style={{ | ||
marginLeft: 190, | ||
marginRight: 190, | ||
display: 'flex', | ||
fontSize: 130, | ||
fontFamily: GeistMono.className, | ||
letterSpacing: '-0.05em', | ||
fontStyle: 'normal', | ||
color: 'white', | ||
lineHeight: '120px', | ||
whiteSpace: 'pre-wrap' | ||
}} | ||
> | ||
{postTitle} | ||
</div> | ||
</div> | ||
), | ||
{ | ||
width: 1920, | ||
height: 1080 | ||
// Optionally, if font needs to be loaded as data | ||
// fonts: [ | ||
// { | ||
// name: 'GeistMono', | ||
// data: font, // Assuming font data is handled accordingly | ||
// style: 'normal' | ||
// } | ||
// ] | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { getThread } from '@/services/hasura'; | ||
import type { Metadata } from 'next'; | ||
import { format } from 'date-fns'; | ||
import { getThreadLink } from './threads'; | ||
|
||
export async function generateMbMetadata({ | ||
params, | ||
}): Promise<Metadata | undefined> { | ||
const thread = await getThread({threadId: params.threadId}) | ||
if (!thread) return | ||
|
||
|
||
const firstQuestion= | ||
thread.messages.find(m => m.role === 'user')?.content || 'not found' | ||
const firstResponse = | ||
thread.messages.find(m => m.role === 'assistant')?.content || 'not found' | ||
|
||
const data = { | ||
title: firstQuestion, | ||
publishedAt: thread.updatedAt, // format(thread.updatedAt, 'MMMM dd, yyyy'), | ||
summary: firstResponse, | ||
image: `https://alpha.masterbots.ai/og?title=${encodeURIComponent(firstQuestion)}`, | ||
pathname: getThreadLink({thread:thread, chat:false}) | ||
} | ||
|
||
return { | ||
title:data.title, | ||
description:data.summary, | ||
openGraph: { | ||
title:data.title, | ||
description:data.summary, | ||
type: 'article', | ||
publishedTime: data.publishedAt, | ||
url: `https://alpha.masterbots.ai/${data.pathname}`, | ||
images: [ | ||
{ | ||
url: data.image, | ||
}, | ||
], | ||
}, | ||
twitter: { | ||
card: 'summary_large_image', | ||
title:data.title, | ||
description:data.summary, | ||
images: [data.image], | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters