@@ -384,7 +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 ] ) => {
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+ results . forEach ( ( { id, game } ) => {
388398 const col = document . createElement ( "div" )
389399 col . className = "col"
390400 row . appendChild ( col )
@@ -398,16 +408,23 @@ function run_search() {
398408 if ( game . cover && game . cover . url ) {
399409 const coverImg = document . createElement ( "img" )
400410 coverImg . className = "card-img-top rounded-top-0"
401- coverImg . src = game . cover . url . replace ( "t_thumb" , "t_cover_small" )
411+ // Convert IGDB URL properly
412+ let coverUrl = game . cover . url
413+ if ( ! coverUrl . startsWith ( 'http' ) ) {
414+ coverUrl = 'https://images.igdb.com/igdb/image/upload/t_cover_big/' + coverUrl . split ( '/' ) . pop ( )
415+ } else {
416+ coverUrl = coverUrl . replace ( "t_thumb" , "t_cover_big" )
417+ }
418+ coverImg . src = coverUrl
402419 coverImg . alt = game . name
403420 coverImg . loading = "lazy"
404- coverImg . style . height = "180px "
421+ coverImg . style . height = "240px "
405422 coverImg . style . objectFit = "cover"
406423 card . appendChild ( coverImg )
407424 } else {
408425 const placeholder = document . createElement ( "div" )
409426 placeholder . className = "card-img-top bg-secondary d-flex align-items-center justify-content-center"
410- placeholder . style . height = "180px "
427+ placeholder . style . height = "240px "
411428 const icon = document . createElement ( "span" )
412429 icon . className = "material-symbols-outlined text-white"
413430 icon . style . fontSize = "3rem"
@@ -422,9 +439,13 @@ function run_search() {
422439
423440 // Game name
424441 const nameEl = document . createElement ( "h6" )
425- nameEl . className = "card-title small mb-2 fw-bold text-truncate "
442+ nameEl . className = "card-title small mb-2 fw-bold"
426443 nameEl . textContent = game . name
427444 nameEl . title = game . name
445+ nameEl . style . overflow = "hidden"
446+ nameEl . style . display = "-webkit-box"
447+ nameEl . style . webkitLineClamp = "2"
448+ nameEl . style . webkitBoxOrient = "vertical"
428449 cardBody . appendChild ( nameEl )
429450
430451 // Platforms with release years
@@ -475,10 +496,19 @@ function run_search() {
475496 moreNote . textContent = `Showing first 60 of ${ matches . length } results. Try a more specific search term.`
476497 search_container . appendChild ( moreNote )
477498 }
499+ } )
478500 } )
479501 . catch ( ( ) => {
480- // Fallback if platforms can't be loaded
481- matches . slice ( 0 , 60 ) . forEach ( ( [ id , game ] ) => {
502+ // Fallback if platforms can't be loaded - still fetch game data
503+ const gamePromises = matches . slice ( 0 , 60 ) . map ( ( [ id , _game ] ) =>
504+ fetch ( `${ base_url } /games/${ id } .json` )
505+ . then ( r => r . ok ? r . json ( ) : null )
506+ . then ( fullGame => ( { id, game : fullGame || { name : _game . name } } ) )
507+ . catch ( ( ) => ( { id, game : { name : _game . name } } ) )
508+ )
509+
510+ Promise . all ( gamePromises ) . then ( results => {
511+ results . forEach ( ( { id, game } ) => {
482512 const col = document . createElement ( "div" )
483513 col . className = "col"
484514 row . appendChild ( col )
@@ -491,14 +521,23 @@ function run_search() {
491521 if ( game . cover && game . cover . url ) {
492522 const coverImg = document . createElement ( "img" )
493523 coverImg . className = "card-img-top rounded-top-0"
494- coverImg . src = game . cover . url . replace ( "t_thumb" , "t_cover_small" )
524+ // Convert IGDB URL properly
525+ let coverUrl = game . cover . url
526+ if ( ! coverUrl . startsWith ( 'http' ) ) {
527+ coverUrl = 'https://images.igdb.com/igdb/image/upload/t_cover_big/' + coverUrl . split ( '/' ) . pop ( )
528+ } else {
529+ coverUrl = coverUrl . replace ( "t_thumb" , "t_cover_big" )
530+ }
531+ coverImg . src = coverUrl
495532 coverImg . alt = game . name
496533 coverImg . loading = "lazy"
534+ coverImg . style . height = "240px"
535+ coverImg . style . objectFit = "cover"
497536 card . appendChild ( coverImg )
498537 } else {
499538 const placeholder = document . createElement ( "div" )
500539 placeholder . className = "card-img-top bg-secondary d-flex align-items-center justify-content-center"
501- placeholder . style . height = "180px "
540+ placeholder . style . height = "240px "
502541 const icon = document . createElement ( "span" )
503542 icon . className = "material-symbols-outlined text-white"
504543 icon . style . fontSize = "3rem"
@@ -512,9 +551,13 @@ function run_search() {
512551 card . appendChild ( cardBody )
513552
514553 const nameEl = document . createElement ( "p" )
515- nameEl . className = "card-text small mb-0"
554+ nameEl . className = "card-text small mb-0 fw-bold "
516555 nameEl . textContent = game . name
517556 nameEl . title = game . name
557+ nameEl . style . overflow = "hidden"
558+ nameEl . style . display = "-webkit-box"
559+ nameEl . style . webkitLineClamp = "2"
560+ nameEl . style . webkitBoxOrient = "vertical"
518561 cardBody . appendChild ( nameEl )
519562 } )
520563
@@ -524,6 +567,7 @@ function run_search() {
524567 moreNote . textContent = `Showing first 60 of ${ matches . length } results. Try a more specific search term.`
525568 search_container . appendChild ( moreNote )
526569 }
570+ } )
527571 } )
528572 } )
529573 . catch ( err => {
0 commit comments