File tree 1 file changed +34
-0
lines changed
frontend/src/app/events/[slug]
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { redirect } from "next/navigation" ;
2
+ import { getEvent } from "@/helpers/getEvent" ;
3
+ import { getStrapiMedia } from "@/helpers/strapi_api" ;
4
+
5
+ export async function generateMetadata ( { params } ) {
6
+
7
+ let slug = params . slug . split ( '-' ) ;
8
+ let event_id = slug [ slug . length - 1 ] ;
9
+ let event = await getEvent ( event_id ) ;
10
+ const { title, body, date_time, sigs } = event . attributes
11
+ const cover_image = getStrapiMedia ( event . attributes . cover_images . data [ 0 ] ?. attributes . url )
12
+
13
+ return {
14
+ metadataBase : new URL ( 'https://webclub.nitk.ac.in' ) ,
15
+ title : title ,
16
+ description : body . substring ( 0 , 200 ) ,
17
+ openGraph : {
18
+ title : title ,
19
+ description : body . substring ( 0 , 200 ) ,
20
+ url : `https://webclub.nitk.ac.in/events/${ params . slug } ` ,
21
+ siteName : "WebClub NITK Event" ,
22
+ images : [
23
+ {
24
+ url : cover_image || 'https://webclub.nitk.ac.in/default-og-image.png' ,
25
+ width : 1200 ,
26
+ height : 630 ,
27
+ alt : title ,
28
+ } ,
29
+ ] ,
30
+ locale : 'en_US' ,
31
+ type : 'article' ,
32
+ publishedTime : date_time ,
33
+ } ,
34
+ }
35
+ }
2
36
3
37
export default async function Page ( { params } ) {
4
38
redirect ( `/events#${ params . slug } ` ) ;
You can’t perform that action at this time.
0 commit comments