File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -160,8 +160,16 @@ function renderVideo(pid, vid) {
160160 const idx = p ? p . videos . findIndex ( ( x ) => x . id === vid ) : - 1 ;
161161 const v = idx >= 0 ? p . videos [ idx ] : null ;
162162 if ( ! v ) return renderHome ( ) ;
163- const docs = v . docs . map ( ( d ) => `<li><a href="${ esc ( d . url ) } " target="_blank" rel="noopener">📄 ${ esc ( d . label ) } </a></li>` ) . join ( "" ) ;
164- const links = v . links . map ( ( l ) => `<li><a href="${ esc ( l . url ) } " target="_blank" rel="noopener">🔗 ${ esc ( l . label ) } </a></li>` ) . join ( "" ) ;
163+ // Accepts both plain URL strings and { label, url } objects.
164+ function renderLink ( item , emoji ) {
165+ const url = typeof item === "string" ? item : item . url ;
166+ const label = typeof item === "string"
167+ ? decodeURIComponent ( url . split ( "/" ) . filter ( Boolean ) . pop ( ) . replace ( / - / g, " " ) )
168+ : item . label ;
169+ return `<li><a href="${ esc ( url ) } " target="_blank" rel="noopener">${ emoji } ${ esc ( label ) } </a></li>` ;
170+ }
171+ const docs = v . docs . map ( ( d ) => renderLink ( d , "📄" ) ) . join ( "" ) ;
172+ const links = v . links . map ( ( l ) => renderLink ( l , "🔗" ) ) . join ( "" ) ;
165173 const playlist = p . videos
166174 . map (
167175 ( item , i ) => `
You can’t perform that action at this time.
0 commit comments