File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
src/project/types/website/listing Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -418,10 +418,26 @@ export function readRenderedContents(
418418 }
419419 } ;
420420
421+ // Try to find a paragraph that doesn't resolve as completely empty
422+ // This could happen, for example, if images are removed from the document
423+ // and the first paragraph is an image.
424+ const getFirstPara = ( ) => {
425+ const paraNodes = mainEl ?. querySelectorAll ( "p" ) ;
426+ if ( paraNodes ) {
427+ for ( const paraNode of paraNodes ) {
428+ const paraContents = cleanMath ( ( paraNode as Element ) . innerHTML ) ;
429+ if ( paraContents ) {
430+ return paraContents ;
431+ }
432+ }
433+ }
434+ return undefined ;
435+ } ;
436+
421437 return {
422438 title : titleText ,
423439 fullContents : cleanMath ( mainEl ?. innerHTML ) ,
424- firstPara : cleanMath ( mainEl ?. querySelector ( "p" ) ?. innerHTML ) ,
440+ firstPara : getFirstPara ( ) ,
425441 } ;
426442}
427443
You can’t perform that action at this time.
0 commit comments