File tree Expand file tree Collapse file tree 5 files changed +36
-4
lines changed Expand file tree Collapse file tree 5 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ export default function PostMedia({
23
23
return false ;
24
24
}
25
25
} ;
26
-
26
+ console . log ( post ) ;
27
27
return (
28
28
< >
29
29
{ post ?. coverVideo && Object . keys ( post . coverVideo ) . length ? (
@@ -82,6 +82,17 @@ export default function PostMedia({
82
82
layout = "responsive"
83
83
priority
84
84
/>
85
+ ) : ! noImage &&
86
+ ( post ?. cover ?. external ?. url || post ?. cover ?. file ?. url ) ? (
87
+ < Image
88
+ loader = { ( { src } ) => src }
89
+ src = { post ?. cover ?. external ?. url || post ?. cover ?. file ?. url || '' }
90
+ alt = { post . title }
91
+ width = "480"
92
+ height = "270"
93
+ layout = "responsive"
94
+ priority
95
+ />
85
96
) : (
86
97
< > </ >
87
98
) }
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ const myMapper = {
35
35
] . includes ( media ?. src ) ? (
36
36
< Image
37
37
className = { `${ className || '' } object-contain ` }
38
- src = { getCloudinaryPublicId ( media ?. src ?. split ( '/' ) ) }
38
+ src = { getCloudinaryPublicId ( media ?. src ) }
39
39
alt = { media ?. alt || media ?. name || '' }
40
40
layout = "fill"
41
41
height = "100%"
Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ export interface Post {
28
28
slug : string ;
29
29
historyId ?: string ;
30
30
postId ?: string ;
31
+ cover ?: {
32
+ external ?: {
33
+ url : string ;
34
+ } ;
35
+ file ?: {
36
+ url : string ;
37
+ } ;
38
+ } ;
31
39
coverPhoto ?: CoverMedia ;
32
40
coverVideo ?: CoverMedia ;
33
41
sections ?: Section [ ] ;
Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ const formatPost = async (
196
196
authors . push ( author ) ;
197
197
}
198
198
}
199
- let coverPublicId = getCloudinaryPublicId ( q ?. cover ?. external ?. url . split ( '/' ) ) ;
199
+ let coverPublicId = getCloudinaryPublicId ( q ?. cover ?. external ?. url ) ;
200
200
post = {
201
201
...post ,
202
202
_id : q ?. id ? q . id : null ,
Original file line number Diff line number Diff line change 1
- export const getCloudinaryPublicId = ( coverSegments : string [ ] ) : string => {
1
+ export const getCloudinaryPublicId = ( cover : string ) : string => {
2
2
let coverPublicId = '' ;
3
+
4
+ const domains = [
5
+ 'main-codingcatdev-photo' ,
6
+ 'ccd-cloudinary' ,
7
+ 'dev-codingcatdev-photo' ,
8
+ ] ;
9
+
10
+ if ( ! domains . some ( ( d ) => cover ?. includes ( d ) ) ) {
11
+ return coverPublicId ;
12
+ }
13
+
14
+ const coverSegments = cover ?. split ( '/' ) ;
15
+
3
16
for ( let i = coverSegments ?. length ; i -- ; i === 0 ) {
4
17
const segment = coverSegments . at ( i ) ;
5
18
if (
You can’t perform that action at this time.
0 commit comments