Skip to content

Commit

Permalink
move og function
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina committed Apr 7, 2024
1 parent 7e46fb4 commit b418484
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 215 deletions.
2 changes: 1 addition & 1 deletion docs/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default async function RootLayout({
}
navbar={
<Navbar
logo={<NextraLogo className="nextra-logo" />}
logo={<NextraLogo className="nextra-logo h-5" />}
projectLink="https://github.com/shuding/nextra"
/>
}
Expand Down
File renamed without changes.
86 changes: 86 additions & 0 deletions docs/app/og/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { NextraLogo } from '@components/icons'
import { ImageResponse } from 'next/og'

export const runtime = 'edge'

const font = fetch(new URL('./Inter-SemiBold.otf', import.meta.url)).then(res =>
res.arrayBuffer()
)

export async function GET(req: Request): Promise<Response> {
try {
const { searchParams } = new URL(req.url)

// ?title=<title>
const title =
searchParams.get('title')?.slice(0, 100) || 'Nextra Documentation'

return new ImageResponse(
(
<div
style={{
height: '100%',
width: '100%',
display: 'flex',
flexDirection: 'column',
alignItems: 'flex-start',
justifyContent: 'center',
padding: 80,
backgroundColor: '#030303',
backgroundImage:
'radial-gradient(circle at 25px 25px, #333 2%, transparent 0%), radial-gradient(circle at 75px 75px, #333 2%, transparent 0%)',
backgroundSize: '100px 100px',
backgroundPosition: '-30px -10px',
fontWeight: 600,
color: 'white'
}}
>
<NextraLogo
style={{ position: 'absolute', top: 70, left: 80 }}
height="40"
/>
<p
style={{
position: 'absolute',
bottom: 70,
left: 80,
margin: 0,
fontSize: 30,
letterSpacing: -1
}}
>
Create beautiful websites with Next.js & MDX.
</p>
<h1
style={{
fontSize: 82,
margin: '0 0 40px -2px',
lineHeight: 1.1,
textShadow: '0 2px 30px #000',
letterSpacing: -4,
backgroundImage: 'linear-gradient(90deg, #fff 40%, #aaa)',
backgroundClip: 'text',
color: 'transparent'
}}
>
{title}
</h1>
</div>
),
{
width: 1200,
height: 630,
fonts: [
{
name: 'inter',
data: await font,
style: 'normal'
}
]
}
)
} catch (error) {
console.error(error)
return new Response('Failed to generate the image', { status: 500 })
}
}
5 changes: 1 addition & 4 deletions docs/components/icons/nextra.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion docs/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
1 change: 0 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"start": "next start"
},
"dependencies": {
"@vercel/og": "^0.5.0",
"clsx": "^2.1.0",
"fast-glob": "^3.3.2",
"framer-motion": "^10.0.0",
Expand Down
100 changes: 0 additions & 100 deletions docs/pages/api/og.jsx

This file was deleted.

Loading

0 comments on commit b418484

Please sign in to comment.