File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ export default defineCachedEventHandler(
126126 swr : true ,
127127 getKey : event => {
128128 const pkg = getRouterParam ( event , 'pkg' ) ?? ''
129- return `readme:v4 :${ pkg . replace ( / \/ + $ / , '' ) . trim ( ) } `
129+ return `readme:v5 :${ pkg . replace ( / \/ + $ / , '' ) . trim ( ) } `
130130 } ,
131131 } ,
132132)
Original file line number Diff line number Diff line change @@ -354,6 +354,25 @@ export async function renderReadmeHtml(
354354 }
355355 return { tagName, attribs }
356356 } ,
357+ source : ( tagName , attribs ) => {
358+ if ( attribs . src ) {
359+ attribs . src = resolveImageUrl ( attribs . src , packageName , repoInfo )
360+ }
361+ if ( attribs . srcset ) {
362+ attribs . srcset = attribs . srcset
363+ . split ( ',' )
364+ . map ( entry => {
365+ const parts = entry . trim ( ) . split ( / \s + / )
366+ const url = parts [ 0 ]
367+ if ( ! url ) return entry . trim ( )
368+ const descriptor = parts [ 1 ]
369+ const resolvedUrl = resolveImageUrl ( url , packageName , repoInfo )
370+ return descriptor ? `${ resolvedUrl } ${ descriptor } ` : resolvedUrl
371+ } )
372+ . join ( ', ' )
373+ }
374+ return { tagName, attribs }
375+ } ,
357376 a : ( tagName , attribs ) => {
358377 // Add security attributes for external links
359378 if ( attribs . href && hasProtocol ( attribs . href , { acceptRelative : true } ) ) {
You can’t perform that action at this time.
0 commit comments