11import { fetchPageById , fetchTableData , fetchNotionUsers } from "../api/notion" ;
22import { parsePageId , getNotionValue } from "../api/utils" ;
3+ import { fetchNotionAsset } from "../api/notion" ;
4+
35import {
46 RowContentType ,
57 CollectionType ,
@@ -33,13 +35,13 @@ export const getCollectionData = async (
3335 b . value && b . value . properties && b . value . parent_id === collection . value . id
3436 ) ;
3537
36- type Row = { id : string ; [ key : string ] : RowContentType } ;
38+ type Row = { id : string ; format : any ; [ key : string ] : RowContentType } ;
3739
3840 const rows : Row [ ] = [ ] ;
39-
41+ const tds = [ ]
4042 for ( const td of tableData ) {
41- let row : Row = { id : td . value . id } ;
42-
43+ let row : Row = { id : td . value . id , format : td . value . format } ;
44+ tds . push ( td )
4345 for ( const key of collectionColKeys ) {
4446 const val = td . value . properties [ key ] ;
4547 if ( val ) {
@@ -51,6 +53,13 @@ export const getCollectionData = async (
5153 }
5254 }
5355 }
56+
57+ if ( row . format && row . format . page_cover ) {
58+ let asset :any = await fetchNotionAsset ( row . format . page_cover , row . id )
59+ if ( asset && asset . url && asset . url . signedUrls && asset . url . signedUrls [ 0 ] )
60+ row . format . page_cover = asset . url . signedUrls [ 0 ]
61+ }
62+
5463 rows . push ( row ) ;
5564 }
5665
@@ -59,7 +68,7 @@ export const getCollectionData = async (
5968
6069
6170
62- return { rows, schema : collectionRows , name } ;
71+ return { rows, schema : collectionRows , name, tableArr } ;
6372} ;
6473
6574
0 commit comments