diff --git a/WebHostLib/static/assets/tutorialLanding.js b/WebHostLib/static/assets/tutorialLanding.js index d00eefa3..b820cc34 100644 --- a/WebHostLib/static/assets/tutorialLanding.js +++ b/WebHostLib/static/assets/tutorialLanding.js @@ -23,6 +23,7 @@ window.addEventListener('load', () => { games.forEach((game) => { const gameTitle = document.createElement('h2'); gameTitle.innerText = game.gameTitle; + gameTitle.id = `${encodeURIComponent(game.gameTitle)}`; tutorialDiv.appendChild(gameTitle); game.tutorials.forEach((tutorial) => { @@ -65,6 +66,15 @@ window.addEventListener('load', () => { showError(); console.error(error); } + + // Check if we are on an anchor when coming in, and scroll to it. + const hash = window.location.hash; + if (hash) { + const offset = 128; // To account for navbar banner at top of page. + window.scrollTo(0, 0); + const rect = document.getElementById(hash.slice(1)).getBoundingClientRect(); + window.scrollTo(rect.left, rect.top - offset); + } }; ajax.open('GET', `${window.location.origin}/static/generated/tutorials.json`, true); ajax.send(); diff --git a/WebHostLib/templates/supportedGames.html b/WebHostLib/templates/supportedGames.html index 00f49d6d..125551fb 100644 --- a/WebHostLib/templates/supportedGames.html +++ b/WebHostLib/templates/supportedGames.html @@ -15,10 +15,15 @@

{{ world.__doc__ | default("No description provided.", true) }}
Game Page + {% if world.web.tutorials %} | + Setup Guides + {% endif %} {% if world.web.settings_page is string %} + | Settings Page {% elif world.web.settings_page %} + | Settings Page {% endif %} {% if world.web.bug_report_page %}