Skip to content

Commit b82e2bd

Browse files
Merge branch 'feature/table-fixes' into feature/notion2site-improvements
* feature/table-fixes: feat: minor table fixes
2 parents bea1c26 + d68ea9a commit b82e2bd

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/block.tsx

+14-6
Original file line numberDiff line numberDiff line change
@@ -290,45 +290,52 @@ export const Block: React.FC<Block> = props => {
290290
);
291291
case "collection_view":
292292
if (!block) return null;
293+
293294
const collectionView = block?.collection?.types[0];
294295

295296
return (
296297
<div>
297298
<h3 className="notion-h3">
298299
{renderChildText(block.collection?.title!)}
299300
</h3>
301+
300302
{collectionView?.type === "table" && (
301303
<div style={{ maxWidth: "100%", marginTop: 5 }}>
302304
<table className="notion-table">
303305
<thead>
304306
<tr className="notion-tr">
305307
{collectionView.format?.table_properties
306308
?.filter(p => p.visible)
307-
.map(gp => (
309+
.map((gp, index) => (
308310
<th
309311
className="notion-th"
312+
key={index}
310313
style={{ minWidth: gp.width }}
311314
>
312-
{block.collection?.schema[gp.property].name}
315+
{block.collection?.schema[gp.property]?.name}
313316
</th>
314317
))}
315318
</tr>
316319
</thead>
320+
317321
<tbody>
318-
{block?.collection?.data.map(row => (
319-
<tr className="notion-tr">
322+
{block?.collection?.data.map((row, index) => (
323+
<tr className="notion-tr" key={index}>
320324
{collectionView.format?.table_properties
321325
?.filter(p => p.visible)
322-
.map(gp => (
326+
.map((gp, index) => (
323327
<td
328+
key={index}
324329
className={
325330
"notion-td " +
326331
(gp.property === "title" ? "notion-bold" : "")
327332
}
328333
>
329334
{
330335
renderChildText(
331-
row[block.collection?.schema[gp.property].name!]
336+
row[
337+
block.collection?.schema[gp.property]?.name!
338+
]
332339
)!
333340
}
334341
</td>
@@ -339,6 +346,7 @@ export const Block: React.FC<Block> = props => {
339346
</table>
340347
</div>
341348
)}
349+
342350
{collectionView?.type === "gallery" && (
343351
<div className="notion-gallery">
344352
{block.collection?.data.map((row, i) => (

src/styles.css

+1
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ img.notion-page-icon {
554554
}
555555

556556
.notion-table {
557+
width: 100%;
557558
border-left: none;
558559
border-right: none;
559560
border-spacing: 0px;

0 commit comments

Comments
 (0)