Skip to content

Commit

Permalink
remove discord widget and add version checking
Browse files Browse the repository at this point in the history
  • Loading branch information
YozoraXCII committed Jun 26, 2024
1 parent 2a82bfc commit 9b8463a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 31 deletions.
32 changes: 21 additions & 11 deletions docs/overrides/main.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
{% extends "base.html" %}

{% block extrahead %}
<script src='https://cdn.jsdelivr.net/npm/@widgetbot/crate@3' async defer>
const button = new Crate({
server: '822460010649878528', // Funky Penguin
channel: '822460010649878531', // #elf-friends channel
username: 'Kometa Website Visitor',
indicator: true,
color: '#00bc8c',
location: ['bottom', 'left']
})
</script>
{% block announce %}
<script>
const currentURL = window.location.href;

// Base announcement for Discord support
let announceText = 'For any questions and support, please reach out to us on <a href="https://kometa.wiki/en/latest/discord/">Discord</a>';

// Check if URL includes nightly or develop
if (currentURL.includes("en/nightly") || currentURL.includes("en/develop")) {

// Find the branch name ("nightly" or "develop")
let branchName = currentURL.includes("en/nightly") ? "NIGHTLY" : "DEVELOP";

// Create a new URL pointing to the "latest" version of the current page
let latestURL = currentURL.replace(/en\/(nightly|develop)\//, 'en/latest/');

// Update the announceText to include the custom link and branch name
announceText = `️⚠️ You are viewing the ${branchName} branch's wiki. <bold><a href="${latestURL}">Click here to go to the main wiki.</a></b> ⚠️️`;
}

document.write(announceText);
</script>
{% endblock %}
39 changes: 19 additions & 20 deletions docs/stylesheets/branch.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
function checkURLForBranch() {
const currentURL = window.location.href;
const ellipsisSpan = document.querySelector(".md-ellipsis");
const mdBanner = document.querySelector(".md-banner"); // Select the banner element

// Select elements for background and text changes
const headerAndTabs = document.querySelectorAll(".md-header, .md-tabs");
const ellipsisSpan = document.querySelector(".md-ellipsis"); // Select ellipsisSpan
// Default text
let ellipsisText = "Kometa Wiki";
let bannerColor = "#252525"; // Default banner color

if (headerAndTabs.length > 0) {
let backgroundImage = "https://raw.githubusercontent.com/Kometa-Team/Kometa/nightly/docs/assets/background.jpg";
let ellipsisText = ""; // Initialize ellipsisText
if (currentURL.includes("en/nightly") || currentURL.includes("en/develop") {
ellipsisText = currentURL.includes("en/nightly") ? "Kometa Nightly Wiki" : "Kometa Develop Wiki";
bannerColor = "#611423"; // Updated banner color
}

if (currentURL.includes("en/nightly")) {
backgroundImage = "https://raw.githubusercontent.com/Kometa-Team/Kometa/nightly/docs/assets/backgroundnightly.jpg";
ellipsisText = "Kometa Nightly Wiki"; // Set text for Nightly
} else if (currentURL.includes("en/develop")) {
backgroundImage = "https://raw.githubusercontent.com/Kometa-Team/Kometa/nightly/docs/assets/backgrounddevelop.jpg";
ellipsisText = "Kometa Develop Wiki"; // Set text for Develop
}
// Create ellipsisSpan if it doesn't exist
if (!ellipsisSpan) {
ellipsisSpan = document.createElement("span");
ellipsisSpan.classList.add("md-ellipsis");
document.body.appendChild(ellipsisSpan);
}

headerAndTabs.forEach(element => {
element.style.backgroundImage = `url(${backgroundImage})`;
});
ellipsisSpan.textContent = ellipsisText;

// Update ellipsisSpan text only if it exists
if (ellipsisSpan) {
ellipsisSpan.textContent = ellipsisText;
}
// Update banner color
if (mdBanner) {
mdBanner.style.backgroundColor = bannerColor;
}
}

Expand Down

0 comments on commit 9b8463a

Please sign in to comment.