File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed
web/src/app/(content)/song/[id] Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change 1+ import { SongViewDtoType } from '@shared/validation/song/dto/types' ;
2+ import type { Metadata } from 'next' ;
3+
4+ import axios from '@web/src/lib/axios' ;
15import { SongPage } from '@web/src/modules/song/components/SongPage' ;
26
3- function Page ( { params } : { params : { id : string } } ) {
7+ interface SongPage {
8+ params : {
9+ id : string ;
10+ } ;
11+ }
12+
13+ export async function generateMetadata ( {
14+ params,
15+ } : SongPage ) : Promise < Metadata > {
16+ let song ;
17+
18+ try {
19+ const response = await axios . get < SongViewDtoType > ( `/song/${ params . id } ` ) ;
20+ song = response . data ;
21+ } catch {
22+ return {
23+ title : 'Unknown song!' ,
24+ } ;
25+ }
26+
27+ return {
28+ title : song . title ,
29+ description : song . description ,
30+ openGraph : {
31+ images : [ song . thumbnailUrl ] ,
32+ } ,
33+ } ;
34+ }
35+
36+ function Page ( { params } : SongPage ) {
437 const { id } = params ;
538
639 return < SongPage id = { id } /> ;
You can’t perform that action at this time.
0 commit comments