File tree Expand file tree Collapse file tree 2 files changed +39
-4
lines changed
Expand file tree Collapse file tree 2 files changed +39
-4
lines changed Original file line number Diff line number Diff line change @@ -46,15 +46,25 @@ export async function generateStaticParams() {
4646 return source . generateParams ( ) ;
4747}
4848
49- export async function generateMetadata ( props : {
49+ export async function generateMetadata ( {
50+ params,
51+ } : {
5052 params : Promise < { slug ?: string [ ] } > ;
5153} ) {
52- const params = await props . params ;
53- const page = source . getPage ( params . slug ) ;
54+ const { slug = [ ] } = await params ;
55+ const page = source . getPage ( slug ) ;
5456 if ( ! page ) notFound ( ) ;
5557
58+ const image = [ '/docs-og' , ...slug , 'image.png' ] . join ( '/' ) ;
5659 return {
5760 title : page . data . title ,
5861 description : page . data . description ,
62+ openGraph : {
63+ images : image ,
64+ } ,
65+ twitter : {
66+ card : 'summary_large_image' ,
67+ images : image ,
68+ } ,
5969 } ;
60- }
70+ }
Original file line number Diff line number Diff line change 1+ import { generateOGImage } from 'fumadocs-ui/og' ;
2+ import { source } from '@/lib/source' ;
3+ import { notFound } from 'next/navigation' ;
4+
5+ export async function GET (
6+ _req : Request ,
7+ { params } : RouteContext < '/docs-og/[...slug]' > ,
8+ ) {
9+ const { slug } = await params ;
10+ const page = source . getPage ( slug . slice ( 0 , - 1 ) ) ;
11+ if ( ! page ) notFound ( ) ;
12+
13+ return generateOGImage ( {
14+ title : page . data . title ,
15+ description : page . data . description ,
16+ site : "Mesh JS - Web3 TypeScript SDK & Off-Chain Framework" ,
17+ } ) ;
18+ }
19+
20+ export function generateStaticParams ( ) {
21+ return source . generateParams ( ) . map ( ( page ) => ( {
22+ ...page ,
23+ slug : [ ...page . slug , 'image.png' ] ,
24+ } ) ) ;
25+ }
You can’t perform that action at this time.
0 commit comments