File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed
Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff 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
115115const 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
You can’t perform that action at this time.
0 commit comments