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,22 @@ 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 [ url , descriptor ] = entry . trim ( ) . split ( / \s + / )
366+ const resolvedUrl = resolveImageUrl ( url , packageName , repoInfo )
367+ return descriptor ? `${ resolvedUrl } ${ descriptor } ` : resolvedUrl
368+ } )
369+ . join ( ', ' )
370+ }
371+ return { tagName, attribs }
372+ } ,
357373 a : ( tagName , attribs ) => {
358374 // Add security attributes for external links
359375 if ( attribs . href && hasProtocol ( attribs . href , { acceptRelative : true } ) ) {
You can’t perform that action at this time.
0 commit comments