From fe71ede8c5e26e6f3756ce2c1e6dd3dfd4557f47 Mon Sep 17 00:00:00 2001 From: taroj1205 Date: Mon, 19 May 2025 23:10:48 +1200 Subject: [PATCH] fix(download): hide flathub download for twilight download page --- src/components/download/DownloadScript.astro | 26 +++++++++---------- .../download/PlatformDownload.astro | 12 ++++----- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/components/download/DownloadScript.astro b/src/components/download/DownloadScript.astro index b8d6033..c58b01b 100644 --- a/src/components/download/DownloadScript.astro +++ b/src/components/download/DownloadScript.astro @@ -26,32 +26,32 @@ // Function to select a platform async function selectPlatform(platform: string) { // Update button styling - platformButtons.forEach((button) => { + for (const button of platformButtons) { const buttonPlatform = button.getAttribute('data-platform') if (buttonPlatform === platform) { button.setAttribute('data-active', 'true') } else { button.setAttribute('data-active', 'false') } - }) + } // Show/hide platform sections - platformSections.forEach((section) => { + for (const section of platformSections) { if (section.id === `${platform}-downloads`) { section.setAttribute('data-active', 'true') } else { section.setAttribute('data-active', 'false') } - }) + } } // Handle platform button clicks - platformButtons.forEach((button) => { + for (const button of platformButtons) { button.addEventListener('click', () => { const platform = button.getAttribute('data-platform') ?? '' selectPlatform(platform) }) - }) + } // Check for twilight mode async function checkTwilightMode() { @@ -70,21 +70,21 @@ } const tags = document.querySelectorAll('.release-type-tag') - tags.forEach((tag) => { + for (const tag of tags) { tag.innerHTML = tag.innerHTML.replace('Beta', 'Twilight') - }) + } // Apply twilight mode to all relevant elements const coralElements = document.querySelectorAll( - '.download-browser-logo, .release-type-tag, .decorative-gradient, .download-link, .download-arrow-icon, .download-card__icon, .checksum-icon-btn, .copy-btn', + '.download-browser-logo, .release-type-tag, .decorative-gradient, .download-link, .download-arrow-icon, .download-card__icon, .checksum-icon-btn, .copy-btn, .flathub-download', ) - coralElements.forEach((element) => { + for (const element of coralElements) { element.setAttribute('data-twilight', 'true') - }) + } // Replace all download links with twilight versions const downloadLinks = document.querySelectorAll('a.download-link') - downloadLinks.forEach((link) => { + for (const link of downloadLinks) { if (!link.id.includes('beta')) { const href = link.getAttribute('href') if (href && href.includes('/latest/download/')) { @@ -95,7 +95,7 @@ link.setAttribute('href', twilightHref) } } - }) + } } } diff --git a/src/components/download/PlatformDownload.astro b/src/components/download/PlatformDownload.astro index 983aef9..f4c0eb9 100644 --- a/src/components/download/PlatformDownload.astro +++ b/src/components/download/PlatformDownload.astro @@ -59,7 +59,7 @@ function isFlatReleaseInfo(obj: unknown): obj is ReleaseInfo { platform === "linux" ? ( <> {releases.flathub && releases.flathub.all.label && ( -
+

Package Managers

-
+ )} {releases.x86_64 && typeof releases.x86_64 === "object" && "tarball" in releases.x86_64 && (releases.x86_64.tarball) && ( -
+

x86_64

{releases.x86_64.tarball && ( @@ -94,13 +94,13 @@ function isFlatReleaseInfo(obj: unknown): obj is ReleaseInfo { /> )}
-
+ )} {releases.aarch64 && typeof releases.aarch64 === "object" && "tarball" in releases.aarch64 && (releases.aarch64.tarball) && ( -
+

ARM64

{releases.aarch64.tarball && ( @@ -120,7 +120,7 @@ function isFlatReleaseInfo(obj: unknown): obj is ReleaseInfo { /> )}
-
+ )} ) : (