Skip to content

Commit 59e61a8

Browse files
Render game artworks in site header
Switch banner/artwork rendering to reuse the existing page header instead of dedicated banner elements. Renamed/repurposed the hidden container from #game-big-imgs to #header-big-imgs, removed the standalone #game-banner-header markup, and injects .img-desc into header.header-section .intro-header as needed. Updated initGameBanner to target the intro-header.big-img, prepend transition nodes there, and guard against missing elements. Also removed an inline max-width on the cover image and cleaned up related markup so the banner integrates with the site's header layout.
1 parent f0bf828 commit 59e61a8

3 files changed

Lines changed: 58 additions & 38 deletions

File tree

gh-pages-template/assets/js/game_detail.js

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,43 @@
77
function renderGame(data) {
88
// Title
99
document.title = (data.name || "Game") + " – GameDB";
10-
document.getElementById("game-name").textContent = data.name || "Unknown Game";
1110

12-
// Banner/Artworks (beautiful-jekyll-next style)
11+
// Set game name in both the page header and the content section
12+
const gameName = data.name || "Unknown Game";
13+
document.getElementById("game-name").textContent = gameName;
14+
15+
// Also set in page header if it exists
16+
const pageHeaderH1 = document.querySelector("header.header-section .page-heading h1");
17+
if (pageHeaderH1) {
18+
pageHeaderH1.textContent = gameName;
19+
}
20+
21+
// Banner/Artworks (inject into existing page header)
1322
if (data.artworks && data.artworks.length > 0) {
14-
const bigImgsEl = document.getElementById("game-big-imgs");
15-
const bannerHeader = document.getElementById("game-banner-header");
16-
17-
// Set data attributes for each artwork
18-
bigImgsEl.setAttribute("data-num-img", data.artworks.length);
19-
data.artworks.forEach((artwork, index) => {
20-
const imgNum = index + 1;
21-
bigImgsEl.setAttribute(`data-img-src-${imgNum}`, igdbImageUrl(artwork.url, "t_screenshot_huge"));
22-
});
23+
const bigImgsEl = document.getElementById("header-big-imgs");
24+
const pageHeader = document.querySelector("header.header-section .intro-header");
25+
26+
if (pageHeader) {
27+
// Set data attributes for each artwork
28+
bigImgsEl.setAttribute("data-num-img", data.artworks.length);
29+
data.artworks.forEach((artwork, index) => {
30+
const imgNum = index + 1;
31+
bigImgsEl.setAttribute(`data-img-src-${imgNum}`, igdbImageUrl(artwork.url, "t_screenshot_huge"));
32+
});
33+
34+
// Add big-img class and img-desc span to existing header
35+
pageHeader.classList.add("big-img");
2336

24-
// Show the banner
25-
bannerHeader.classList.remove("d-none");
37+
// Add img-desc span if it doesn't exist
38+
if (!pageHeader.querySelector(".img-desc")) {
39+
const imgDesc = document.createElement("span");
40+
imgDesc.className = "img-desc";
41+
pageHeader.appendChild(imgDesc);
42+
}
2643

27-
// Initialize the image display (mimics beautifuljekyll.js behavior)
28-
initGameBanner();
44+
// Initialize the image display
45+
initGameBanner();
46+
}
2947
}
3048

3149
// Cover
@@ -364,11 +382,15 @@ function getRegionFlag(regionName) {
364382
* Initialize game banner with cycling images (mimics beautiful-jekyll-next behavior)
365383
*/
366384
function initGameBanner() {
367-
const bigImgsEl = document.getElementById("game-big-imgs");
385+
const bigImgsEl = document.getElementById("header-big-imgs");
368386
const numImgs = parseInt(bigImgsEl.getAttribute("data-num-img"));
369387

370388
if (!numImgs || numImgs === 0) return;
371389

390+
// Target the existing page header
391+
const introHeader = document.querySelector("header.header-section .intro-header.big-img");
392+
if (!introHeader) return;
393+
372394
// Set initial image
373395
const getImgInfo = function(imgNum) {
374396
const src = bigImgsEl.getAttribute(`data-img-src-${imgNum}`);
@@ -377,15 +399,16 @@ function initGameBanner() {
377399
};
378400

379401
const setImg = function(src, desc) {
380-
const bannerHeader = document.getElementById("game-banner-header");
381-
bannerHeader.style.backgroundImage = `url(${src})`;
382-
383-
const imgDesc = bannerHeader.querySelector(".img-desc");
384-
if (desc && desc !== "null") {
385-
imgDesc.textContent = desc;
386-
imgDesc.style.display = "block";
387-
} else {
388-
imgDesc.style.display = "none";
402+
introHeader.style.backgroundImage = `url(${src})`;
403+
404+
const imgDesc = introHeader.querySelector(".img-desc");
405+
if (imgDesc) {
406+
if (desc && desc !== "null") {
407+
imgDesc.textContent = desc;
408+
imgDesc.style.display = "block";
409+
} else {
410+
imgDesc.style.display = "none";
411+
}
389412
}
390413
};
391414

@@ -411,7 +434,7 @@ function initGameBanner() {
411434
const img = document.createElement("div");
412435
img.className = "big-img-transition";
413436
img.style.backgroundImage = `url(${src})`;
414-
document.getElementById("game-banner-header").prepend(img);
437+
introHeader.prepend(img);
415438

416439
setTimeout(function() {
417440
img.style.opacity = "1";

gh-pages-template/assets/js/item_loader.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ let base_url = window.location.origin + base_path;
99
// get platforms container
1010
let platforms_container = document.getElementById("platforms-container")
1111

12-
1312
$(document).ready(function(){
1413
// Set cache = false for all jquery ajax requests.
1514
$.ajaxSetup({
@@ -141,7 +140,6 @@ $(document).ready(function(){
141140
let sorted = platforms.sort(window.rankingSorter("name", "id")).reverse()
142141

143142
for(let item in sorted) {
144-
145143
let column = document.createElement("div")
146144
column.className = "col-lg-4 mb-5"
147145
platforms_container.appendChild(column)

gh-pages-template/browse/games.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
---
2-
title: Game
32
layout: page
43
full-width: false
5-
css:
6-
- /assets/css/hide-heading.css
4+
cover-img: "https://via.placeholder.com/1920x400/333/333"
75
js:
86
- /GameDB/assets/js/item_detail.js
97
- /GameDB/assets/js/game_detail.js
108
ext-css:
119
- href: https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200
1210
---
1311

12+
<style>
13+
.page-heading h1 {
14+
display: none;
15+
}
16+
</style>
17+
1418
<script>
1519
window.GAMEDB_CONFIG = {
1620
base_path: "{{ site.baseurl }}"
@@ -29,17 +33,12 @@
2933
<div id="item-content" class="d-none">
3034

3135
<!-- Banner Images (hidden, holds data attributes) -->
32-
<div id="game-big-imgs" style="display:none;"></div>
33-
34-
<!-- Banner Header (styled like beautiful-jekyll-next cover-img) -->
35-
<div id="game-banner-header" class="intro-header big-img d-none" style="margin-top: -70px; margin-bottom: 30px;">
36-
<span class='img-desc'></span>
37-
</div>
36+
<div id="header-big-imgs" style="display:none;"></div>
3837

3938
<div class="row gx-4 gy-4 mb-4">
4039
<!-- Cover image -->
4140
<div class="col-12 col-lg-3 col-md-4 text-center">
42-
<img id="game-cover" src="" alt="" class="img-fluid rounded shadow w-100" style="max-width:300px; display:none;">
41+
<img id="game-cover" src="" alt="" class="img-fluid rounded shadow w-100" style="display:none;">
4342
<div id="game-cover-placeholder" class="bg-secondary d-flex align-items-center justify-content-center rounded"
4443
style="min-height:300px; display:none !important;">
4544
<span class="material-symbols-outlined text-white" style="font-size:5rem;">sports_esports</span>

0 commit comments

Comments
 (0)