File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -13,20 +13,23 @@ const SingularBlogPost: React.FC<SingularBlogPostProps> = ({
13
13
title,
14
14
} ) => {
15
15
const [ imgError , setImgError ] = useState ( false ) ;
16
-
16
+
17
17
// Validate URL to ensure it's properly formatted
18
18
const isValidUrl = ( urlString : string ) : boolean => {
19
19
try {
20
20
return Boolean ( new URL ( urlString ) ) ;
21
21
} catch ( error ) {
22
- console . error ( "Invalid URL:" , error ) ;
22
+ console . log ( "Invalid URL:" , error ) ;
23
23
return false ;
24
24
}
25
25
} ;
26
26
27
+ console . log ( "Checking for valid url" )
28
+ console . log ( isValidUrl ( imageUrl ) )
29
+ console . log ( imageUrl )
27
30
// Default image URL to use when image is invalid or fails to load
28
31
const defaultImageUrl = "https://images.unsplash.com/photo-1669352311123-085520652a65?q=80&w=2071&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D" ;
29
-
32
+
30
33
// Determine which image URL to use
31
34
const safeImageUrl = imgError || ! isValidUrl ( imageUrl ) ? defaultImageUrl : imageUrl ;
32
35
@@ -90,4 +93,5 @@ const SingularBlogPost: React.FC<SingularBlogPostProps> = ({
90
93
) ;
91
94
} ;
92
95
93
- export default SingularBlogPost ;
96
+ export default SingularBlogPost ;
97
+
You can’t perform that action at this time.
0 commit comments