@@ -3,6 +3,7 @@ import { podcastQuery, postQuery } from "@/sanity/lib/queries";
33import { isValidSignature , SIGNATURE_HEADER_NAME } from "@sanity/webhook" ;
44import toMarkdown from "@sanity/block-content-to-markdown" ;
55import { createClient } from "next-sanity" ;
6+ import { urlForImage } from "@/sanity/lib/utils" ;
67
78const secret = process . env . PRIVATE_SYNDICATE_WEBOOK_SECRET ;
89import { apiVersion , dataset , projectId , studioUrl } from "@/sanity/lib/api" ;
@@ -81,10 +82,7 @@ const formatPodcast = async (_type: string, slug: string) => {
8182 title : podcast . title ,
8283 published : true ,
8384 tags : [ "webdev" , "javascript" , "beginners" ] ,
84- main_image : podcast ?. coverImage ?. secure_url ?. replace (
85- "upload/" ,
86- "upload/b_rgb:5e1186,c_pad,w_1000,h_420/" ,
87- ) ,
85+ main_image : urlForImage ( podcast ?. coverImage ) ?. width ( 1000 ) . height ( 420 ) . url ( ) || "" ,
8886 canonical_url : `https://codingcat.dev/${ podcast . _type } /${ podcast . slug } ` ,
8987 description : podcast ?. excerpt || "" ,
9088 organization_id : "1009" ,
@@ -239,7 +237,12 @@ const serializers = {
239237 types : {
240238 code : ( props : any ) =>
241239 "```" + props ?. node ?. language + "\n" + props ?. node ?. code + "\n```" ,
242- "cloudinary.asset" : ( props : any ) => `` ,
240+ image : ( props : any ) => {
241+ const url = props ?. node ?. asset ?. _ref
242+ ? urlForImage ( props . node ) ?. url ( )
243+ : "" ;
244+ return `` ;
245+ } ,
243246 codepen : ( props : any ) => `{% codepen ${ props ?. node ?. url } %}` ,
244247 codesandbox : ( props : any ) =>
245248 `{% codesandbox ${ props ?. node ?. url ?. split ( "https://codesandbox.io/p/sandbox/" ) ?. at ( - 1 ) } %}` ,
0 commit comments