Skip to content

Commit 1f9d747

Browse files
committed
closer
1 parent c02e6a9 commit 1f9d747

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

bin/shelf.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,16 @@ const cleanupDataFields = async (notionResponse) => {
8585
*
8686
* Note that final state is not necessarily easiest implementation for this code, but for my personal workflow.
8787
*/
88-
// if (!cleanBook.review) {
89-
const pageBlocks = await notion.blocks.children.list({
90-
block_id: book.id,
91-
page_size: 100,
92-
});
93-
if (pageBlocks.results.length > 0) {
94-
const htmlReview = reduceBlocksToSingleHTMLString(pageBlocks.results);
95-
if (htmlReview !== "") cleanBook.review = htmlReview;
88+
if (!cleanBook.review) {
89+
const pageBlocks = await notion.blocks.children.list({
90+
block_id: book.id,
91+
page_size: 100,
92+
});
93+
if (pageBlocks.results.length > 0) {
94+
const htmlReview = reduceBlocksToSingleHTMLString(pageBlocks.results);
95+
if (htmlReview !== "") cleanBook.review = htmlReview;
96+
}
9697
}
97-
// }
9898

9999
return cleanBook;
100100
});
@@ -113,10 +113,12 @@ const reduceRichTextToHTMLString = (richTextArray) => {
113113
};
114114

115115
const reduceBlocksToSingleHTMLString = (blockList) => {
116-
console.dir(blockList, { depth: null });
117116
return blockList.reduce((finalText, currentBlock) => {
118117
// Only interested in text stuff
119-
if (currentBlock.type !== "paragraph" || !current.paragraph.rich_text) {
118+
if (
119+
currentBlock.type !== "paragraph" ||
120+
currentBlock.paragraph.rich_text.length === 0
121+
) {
120122
return finalText;
121123
}
122124

0 commit comments

Comments
 (0)