fix(search): 🐛 more robust null check for description

This commit is contained in:
alistair3149 2023-01-09 16:24:28 -05:00
parent 7bd30ebecb
commit 1e47e95a8d
No known key found for this signature in database

View file

@ -75,8 +75,13 @@ function convertDataToResults( data ) {
case 'textextracts':
return item.extract || '';
case 'pagedescription':
/* eslint-disable-next-line es-x/no-symbol-prototype-description */
return item.pageprops.description.slice( 0, 60 ) + '...' || '';
/* eslint-disable es-x/no-symbol-prototype-description */
if ( item.pageprops && item.pageprops.description ) {
return item.pageprops.description.slice( 0, 60 ) + '...';
/* eslint-enable es-x/no-symbol-prototype-description */
} else {
return '';
}
}
};