Skip to content

Commit 141d591

Browse files
committed
bug fixes
1 parent 54d1498 commit 141d591

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/api/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export interface RowType {
9696
value: {
9797
id: string;
9898
parent_id: string;
99+
format: any;
99100
properties: { [key: string]: DecorationType[] };
100101
};
101102
}

src/routes/collection.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { fetchPageById, fetchTableData, fetchNotionUsers } from "../api/notion";
22
import { parsePageId, getNotionValue } from "../api/utils";
3+
import { fetchNotionAsset } from "../api/notion";
4+
35
import {
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

Comments
 (0)