File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
apps/web/app/tracks/[...trackIds] Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,21 @@ import { LessonView } from "../../../components/LessonView";
66
77const notion = new NotionAPI ( ) ;
88export const dynamic = "force-dynamic" ;
9+
10+ // Normalize Notion record map to handle nested value.value structure
11+ function normalizeRecordMap ( recordMap : any ) {
12+ if ( ! recordMap ?. block ) return recordMap ;
13+ const normalizedBlock : any = { } ;
14+ for ( const [ key , block ] of Object . entries ( recordMap . block ) as any ) {
15+ if ( block ?. value ?. value ) {
16+ normalizedBlock [ key ] = { ...block , value : block . value . value } ;
17+ } else {
18+ normalizedBlock [ key ] = block ;
19+ }
20+ }
21+ return { ...recordMap , block : normalizedBlock } ;
22+ }
23+
924// Dynamic Metadata
1025export async function generateMetadata ( { params } : { params : { trackIds : string [ ] } } ) {
1126 const trackId = params . trackIds [ 0 ] || "" ;
@@ -59,7 +74,8 @@ export default async function TrackComponent({ params }: { params: { trackIds: s
5974 }
6075
6176 if ( problemDetails ?. notionDocId ) {
62- notionRecordMap = await notion . getPage ( problemDetails . notionDocId ) ;
77+ const rawRecordMap = await notion . getPage ( problemDetails . notionDocId ) ;
78+ notionRecordMap = normalizeRecordMap ( rawRecordMap ) ;
6379 }
6480
6581 if ( trackDetails && problemDetails ) {
You can’t perform that action at this time.
0 commit comments