@@ -267,6 +267,84 @@ export const Block: React.FC<Block> = props => {
267
267
{ renderChildText ( blockValue . properties . title ) }
268
268
</ blockquote >
269
269
) ;
270
+ case "collection_view" :
271
+ if ( ! block ) return null ;
272
+ const collectionView = block ?. collection ?. types [ 0 ] ;
273
+
274
+ return (
275
+ < div >
276
+ < h3 className = "notion-h3" >
277
+ { renderChildText ( block . collection ?. title ! ) }
278
+ </ h3 >
279
+ { collectionView ?. type === "table" && (
280
+ < div style = { { maxWidth : "100%" , marginTop : 5 } } >
281
+ < table className = "notion-table" >
282
+ < thead >
283
+ < tr className = "notion-tr" >
284
+ { collectionView . format ?. table_properties
285
+ ?. filter ( p => p . visible )
286
+ . map ( gp => (
287
+ < th
288
+ className = "notion-th"
289
+ style = { { minWidth : gp . width } }
290
+ >
291
+ { block . collection ?. schema [ gp . property ] . name }
292
+ </ th >
293
+ ) ) }
294
+ </ tr >
295
+ </ thead >
296
+ < tbody >
297
+ { block ?. collection ?. data . map ( row => (
298
+ < tr className = "notion-tr" >
299
+ { collectionView . format ?. table_properties
300
+ ?. filter ( p => p . visible )
301
+ . map ( gp => (
302
+ < td
303
+ className = {
304
+ "notion-td " +
305
+ ( gp . property === "title" ? "notion-bold" : "" )
306
+ }
307
+ >
308
+ {
309
+ renderChildText (
310
+ row [ block . collection ?. schema [ gp . property ] . name ! ]
311
+ ) !
312
+ }
313
+ </ td >
314
+ ) ) }
315
+ </ tr >
316
+ ) ) }
317
+ </ tbody >
318
+ </ table >
319
+ </ div >
320
+ ) }
321
+ { collectionView ?. type === "gallery" && (
322
+ < div className = "notion-gallery" >
323
+ { block . collection ?. data . map ( ( row , i ) => (
324
+ < div key = { `col-${ i } ` } className = "notion-gallery-card" >
325
+ < div className = "notion-gallery-content" >
326
+ { collectionView . format ?. gallery_properties
327
+ ?. filter ( p => p . visible )
328
+ . map ( ( gp , idx ) => (
329
+ < p
330
+ key = { idx + "item" }
331
+ className = {
332
+ "notion-gallery-data " +
333
+ ( idx === 0 ? "is-first" : "" )
334
+ }
335
+ >
336
+ { getTextContent (
337
+ row [ block . collection ?. schema [ gp . property ] . name ! ]
338
+ ) }
339
+ </ p >
340
+ ) ) }
341
+ </ div >
342
+ </ div >
343
+ ) ) }
344
+ </ div >
345
+ ) }
346
+ </ div >
347
+ ) ;
270
348
case "callout" :
271
349
return (
272
350
< div
@@ -285,39 +363,53 @@ export const Block: React.FC<Block> = props => {
285
363
</ div >
286
364
) ;
287
365
case "bookmark" :
366
+ const link = blockValue . properties . link
367
+ const title = blockValue . properties . title ?? link
368
+ const description = blockValue . properties . description
369
+ const block_color = blockValue . format ?. block_color
370
+ const bookmark_icon = blockValue . format ?. bookmark_icon
371
+ const bookmark_cover = blockValue . format ?. bookmark_cover
372
+
288
373
return (
289
374
< div className = "notion-row" >
290
375
< a
291
376
target = "_blank"
292
377
rel = "noopener noreferrer"
293
378
className = { classNames (
294
379
"notion-bookmark" ,
295
- blockValue . format . block_color &&
296
- `notion-${ blockValue . format . block_color } `
380
+ block_color &&
381
+ `notion-${ block_color } `
297
382
) }
298
- href = { blockValue . properties . link [ 0 ] [ 0 ] }
383
+ href = { link [ 0 ] [ 0 ] }
299
384
>
300
385
< div >
301
386
< div className = "notion-bookmark-title" >
302
- { renderChildText ( blockValue . properties . title ) }
303
- </ div >
304
- < div className = "notion-bookmark-description" >
305
- { renderChildText ( blockValue . properties . description ) }
387
+ { renderChildText ( title ) }
306
388
</ div >
389
+ { description && (
390
+ < div className = "notion-bookmark-description" >
391
+ { renderChildText ( description ) }
392
+ </ div >
393
+ ) }
394
+
307
395
< div className = "notion-bookmark-link" >
396
+ { bookmark_icon && (
397
+ < img
398
+ src = { bookmark_icon }
399
+ alt = { getTextContent ( title ) }
400
+ />
401
+ ) }
402
+ < div > { renderChildText ( link ) } </ div >
403
+ </ div >
404
+ </ div >
405
+ { bookmark_cover && (
406
+ < div className = "notion-bookmark-image" >
308
407
< img
309
- src = { blockValue . format . bookmark_icon }
310
- alt = { getTextContent ( blockValue . properties . title ) }
408
+ src = { bookmark_cover }
409
+ alt = { getTextContent ( title ) }
311
410
/>
312
- < div > { renderChildText ( blockValue . properties . link ) } </ div >
313
411
</ div >
314
- </ div >
315
- < div className = "notion-bookmark-image" >
316
- < img
317
- src = { blockValue . format . bookmark_cover }
318
- alt = { getTextContent ( blockValue . properties . title ) }
319
- />
320
- </ div >
412
+ ) }
321
413
</ a >
322
414
</ div >
323
415
) ;
0 commit comments