WebHost: Add links to "Setup Guides" in Supported Games page (#847)

* WebHost: Add links to "Setup Guides" in Supported Games page

* Remove a hanging console.log() I left in
This commit is contained in:
Zach Parks 2022-07-31 15:17:26 +00:00 committed by GitHub
parent 3bc9392e5b
commit d1f34d088b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -23,6 +23,7 @@ window.addEventListener('load', () => {
games.forEach((game) => { games.forEach((game) => {
const gameTitle = document.createElement('h2'); const gameTitle = document.createElement('h2');
gameTitle.innerText = game.gameTitle; gameTitle.innerText = game.gameTitle;
gameTitle.id = `${encodeURIComponent(game.gameTitle)}`;
tutorialDiv.appendChild(gameTitle); tutorialDiv.appendChild(gameTitle);
game.tutorials.forEach((tutorial) => { game.tutorials.forEach((tutorial) => {
@ -65,6 +66,15 @@ window.addEventListener('load', () => {
showError(); showError();
console.error(error); 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.open('GET', `${window.location.origin}/static/generated/tutorials.json`, true);
ajax.send(); ajax.send();

View File

@ -15,10 +15,15 @@
<p> <p>
{{ world.__doc__ | default("No description provided.", true) }}<br /> {{ world.__doc__ | default("No description provided.", true) }}<br />
<a href="{{ url_for("game_info", game=game_name, lang="en") }}">Game Page</a> <a href="{{ url_for("game_info", game=game_name, lang="en") }}">Game Page</a>
{% if world.web.tutorials %}
<span class="link-spacer">|</span> <span class="link-spacer">|</span>
<a href="{{ url_for("tutorial_landing") }}#{{ game_name }}">Setup Guides</a>
{% endif %}
{% if world.web.settings_page is string %} {% if world.web.settings_page is string %}
<span class="link-spacer">|</span>
<a href="{{ world.web.settings_page }}">Settings Page</a> <a href="{{ world.web.settings_page }}">Settings Page</a>
{% elif world.web.settings_page %} {% elif world.web.settings_page %}
<span class="link-spacer">|</span>
<a href="{{ url_for("player_settings", game=game_name) }}">Settings Page</a> <a href="{{ url_for("player_settings", game=game_name) }}">Settings Page</a>
{% endif %} {% endif %}
{% if world.web.bug_report_page %} {% if world.web.bug_report_page %}