@@ -1098,7 +1098,8 @@ app.get("/blog/:slug", async (req,res) => {
10981098
10991099 console . log ( parsedData )
11001100 const pageContent = await getBlocks ( response . id )
1101- const postHTML = parsePageContentHTML ( pageContent )
1101+ let postHTML = parsePageContentHTML ( pageContent )
1102+ console . log ( postHTML )
11021103 res . render ( "blog/post" , { title : parsedData . Name , postHTML :postHTML , ...parsedData } )
11031104} )
11041105
@@ -2215,13 +2216,19 @@ function parseBlockIntoKeyedObject(block, contentObj) {
22152216 }
22162217}
22172218function parsePageContentHTML ( data ) {
2218- let pageHTML = ""
2219+ let pageHTML = [ ]
2220+ let htmlString = ""
22192221 let prevType = ""
22202222 console . log ( "parsing" )
22212223 for ( let i = 0 ; i < data . length ; i ++ ) {
2222- pageHTML = parseBlockHTML ( data [ i ] , pageHTML , prevType )
2224+ htmlString = parseBlockHTML ( data [ i ] , htmlString , prevType )
2225+ if ( htmlString . length > 10000 ) {
2226+ pageHTML . push ( htmlString )
2227+ htmlString = ""
2228+ }
22232229 prevType = data [ i ] . type
22242230 }
2231+ pageHTML . push ( htmlString )
22252232 return pageHTML
22262233}
22272234
@@ -2239,7 +2246,7 @@ function parseBlockHTML(block, pageHTML, prevType) {
22392246 case 'heading_3' :
22402247 // For a heading
22412248 console . log ( block [ 'heading_3' ] )
2242- if ( block [ 'heading_3' ] ?. text [ 0 ] . plain_text ?. indexOf ( "http" ) == 0 ) {
2249+ if ( block [ 'heading_3' ] ?. text [ 0 ] ? .plain_text ?. indexOf ( "http" ) == 0 ) {
22432250 console . log ( "URL DETECTED" )
22442251 return pageHTML += `<iframe src='${ block [ 'heading_3' ] . text [ 0 ] . href } '></iframe>`
22452252 }
0 commit comments