@@ -384,8 +384,17 @@ function run_search() {
384384 fetch ( `${ base_url } /platforms/all.json` )
385385 . then ( r => r . json ( ) )
386386 . then ( allPlatforms => {
387- matches . slice ( 0 , 60 ) . forEach ( ( [ id , game ] ) => {
388- const col = document . createElement ( "div" )
387+ // Fetch full game data for each match
388+ const gamePromises = matches . slice ( 0 , 60 ) . map ( ( [ id , _game ] ) =>
389+ fetch ( `${ base_url } /games/${ id } .json` )
390+ . then ( r => r . ok ? r . json ( ) : null )
391+ . then ( fullGame => ( { id, game : fullGame || { name : _game . name } } ) )
392+ . catch ( ( ) => ( { id, game : { name : _game . name } } ) )
393+ )
394+
395+ Promise . all ( gamePromises ) . then ( results => {
396+ results . forEach ( ( { id, game } ) => {
397+ const col = document . createElement ( "div" )
389398 col . className = "col"
390399 row . appendChild ( col )
391400
@@ -398,16 +407,23 @@ function run_search() {
398407 if ( game . cover && game . cover . url ) {
399408 const coverImg = document . createElement ( "img" )
400409 coverImg . className = "card-img-top rounded-top-0"
401- coverImg . src = game . cover . url . replace ( "t_thumb" , "t_cover_small" )
410+ // Convert IGDB URL properly
411+ let coverUrl = game . cover . url
412+ if ( ! coverUrl . startsWith ( 'http' ) ) {
413+ coverUrl = 'https://images.igdb.com/igdb/image/upload/t_cover_big/' + coverUrl . split ( '/' ) . pop ( )
414+ } else {
415+ coverUrl = coverUrl . replace ( "t_thumb" , "t_cover_big" )
416+ }
417+ coverImg . src = coverUrl
402418 coverImg . alt = game . name
403419 coverImg . loading = "lazy"
404- coverImg . style . height = "180px "
420+ coverImg . style . height = "240px "
405421 coverImg . style . objectFit = "cover"
406422 card . appendChild ( coverImg )
407423 } else {
408424 const placeholder = document . createElement ( "div" )
409425 placeholder . className = "card-img-top bg-secondary d-flex align-items-center justify-content-center"
410- placeholder . style . height = "180px "
426+ placeholder . style . height = "240px "
411427 const icon = document . createElement ( "span" )
412428 icon . className = "material-symbols-outlined text-white"
413429 icon . style . fontSize = "3rem"
@@ -422,9 +438,13 @@ function run_search() {
422438
423439 // Game name
424440 const nameEl = document . createElement ( "h6" )
425- nameEl . className = "card-title small mb-2 fw-bold text-truncate "
441+ nameEl . className = "card-title small mb-2 fw-bold"
426442 nameEl . textContent = game . name
427443 nameEl . title = game . name
444+ nameEl . style . overflow = "hidden"
445+ nameEl . style . display = "-webkit-box"
446+ nameEl . style . webkitLineClamp = "2"
447+ nameEl . style . webkitBoxOrient = "vertical"
428448 cardBody . appendChild ( nameEl )
429449
430450 // Platforms with release years
@@ -475,10 +495,19 @@ function run_search() {
475495 moreNote . textContent = `Showing first 60 of ${ matches . length } results. Try a more specific search term.`
476496 search_container . appendChild ( moreNote )
477497 }
498+ } )
478499 } )
479500 . catch ( ( ) => {
480- // Fallback if platforms can't be loaded
481- matches . slice ( 0 , 60 ) . forEach ( ( [ id , game ] ) => {
501+ // Fallback if platforms can't be loaded - still fetch game data
502+ const gamePromises = matches . slice ( 0 , 60 ) . map ( ( [ id , _game ] ) =>
503+ fetch ( `${ base_url } /games/${ id } .json` )
504+ . then ( r => r . ok ? r . json ( ) : null )
505+ . then ( fullGame => ( { id, game : fullGame || { name : _game . name } } ) )
506+ . catch ( ( ) => ( { id, game : { name : _game . name } } ) )
507+ )
508+
509+ Promise . all ( gamePromises ) . then ( results => {
510+ results . forEach ( ( { id, game } ) => {
482511 const col = document . createElement ( "div" )
483512 col . className = "col"
484513 row . appendChild ( col )
@@ -491,14 +520,23 @@ function run_search() {
491520 if ( game . cover && game . cover . url ) {
492521 const coverImg = document . createElement ( "img" )
493522 coverImg . className = "card-img-top rounded-top-0"
494- coverImg . src = game . cover . url . replace ( "t_thumb" , "t_cover_small" )
523+ // Convert IGDB URL properly
524+ let coverUrl = game . cover . url
525+ if ( ! coverUrl . startsWith ( 'http' ) ) {
526+ coverUrl = 'https://images.igdb.com/igdb/image/upload/t_cover_big/' + coverUrl . split ( '/' ) . pop ( )
527+ } else {
528+ coverUrl = coverUrl . replace ( "t_thumb" , "t_cover_big" )
529+ }
530+ coverImg . src = coverUrl
495531 coverImg . alt = game . name
496532 coverImg . loading = "lazy"
533+ coverImg . style . height = "240px"
534+ coverImg . style . objectFit = "cover"
497535 card . appendChild ( coverImg )
498536 } else {
499537 const placeholder = document . createElement ( "div" )
500538 placeholder . className = "card-img-top bg-secondary d-flex align-items-center justify-content-center"
501- placeholder . style . height = "180px "
539+ placeholder . style . height = "240px "
502540 const icon = document . createElement ( "span" )
503541 icon . className = "material-symbols-outlined text-white"
504542 icon . style . fontSize = "3rem"
@@ -512,9 +550,13 @@ function run_search() {
512550 card . appendChild ( cardBody )
513551
514552 const nameEl = document . createElement ( "p" )
515- nameEl . className = "card-text small mb-0"
553+ nameEl . className = "card-text small mb-0 fw-bold "
516554 nameEl . textContent = game . name
517555 nameEl . title = game . name
556+ nameEl . style . overflow = "hidden"
557+ nameEl . style . display = "-webkit-box"
558+ nameEl . style . webkitLineClamp = "2"
559+ nameEl . style . webkitBoxOrient = "vertical"
518560 cardBody . appendChild ( nameEl )
519561 } )
520562
@@ -524,6 +566,7 @@ function run_search() {
524566 moreNote . textContent = `Showing first 60 of ${ matches . length } results. Try a more specific search term.`
525567 search_container . appendChild ( moreNote )
526568 }
569+ } )
527570 } )
528571 } )
529572 . catch ( err => {
0 commit comments