From 68dc81ac964080b0caae51fbf30fd5b0a29a973b Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 14 Jun 2025 14:13:17 +0300 Subject: [PATCH] feat(website): integrate download matrix for server --- apps/website/src/lib/download-helper.ts | 84 ++++++++++++-- apps/website/src/routes/download/+page.svelte | 108 +++++++----------- 2 files changed, 113 insertions(+), 79 deletions(-) diff --git a/apps/website/src/lib/download-helper.ts b/apps/website/src/lib/download-helper.ts index b3b40f8a9..b695827d9 100644 --- a/apps/website/src/lib/download-helper.ts +++ b/apps/website/src/lib/download-helper.ts @@ -1,13 +1,81 @@ -function getArchitecture() { +export type Architecture = 'x64' | 'arm64'; + +type Platform = 'mac' | 'windows' | 'linux'; + +type Apps = 'desktop'; + +export const downloadMatrix = { + desktop: { + windows: { + title: "Windows", + downloads: { + exe: { + recommended: true, + name: "Installer (.exe)", + x64: "https://github.com/TriliumNext/Notes/releases/download/nightly/TriliumNextNotes-develop-windows-x64.exe", + arm64: "https://github.com/TriliumNext/Notes/releases/download/nightly/TriliumNextNotes-develop-windows-arm64.exe" + }, + zip: { + name: "Portable (.zip)", + x64: "https://github.com/TriliumNext/Notes/releases/download/nightly/TriliumNextNotes-develop-windows-x64.zip", + arm64: "https://github.com/TriliumNext/Notes/releases/download/nightly/TriliumNextNotes-develop-windows-arm64.zip" + } + } + }, + linux: { + title: "Linux", + downloads: { + deb: { + name: "Debian/Ubuntu (.deb)", + x64: "https://github.com/TriliumNext/Notes/releases/download/nightly/TriliumNextNotes-develop-linux-x64.deb", + arm64: "https://github.com/TriliumNext/Notes/releases/download/nightly/TriliumNextNotes-develop-linux-arm64.deb" + }, + rpm: { + name: "Red Hat-based distributions (.rpm)", + x64: "https://github.com/TriliumNext/Notes/releases/download/nightly/TriliumNextNotes-develop-linux-x64.rpm", + arm64: "https://github.com/TriliumNext/Notes/releases/download/nightly/TriliumNextNotes-develop-linux-arm64.rpm" + }, + flatpak: { + name: "Flatpak (.flatpak)", + x64: "https://github.com/TriliumNext/Notes/releases/download/nightly/TriliumNextNotes-develop-linux-x64.flatpak", + arm64: "https://github.com/TriliumNext/Notes/releases/download/nightly/TriliumNextNotes-develop-linux-arm64.flatpak" + }, + zip: { + name: "Portable (.zip)", + x64: "https://github.com/TriliumNext/Notes/releases/download/nightly/TriliumNextNotes-develop-linux-x64.zip", + arm64: "https://github.com/TriliumNext/Notes/releases/download/nightly/TriliumNextNotes-develop-linux-arm64.zip" + } + } + }, + mac: { + title: "macOS", + downloads: { + dmg: { + recommended: true, + name: "Installer (.dmg)", + x64: "https://github.com/TriliumNext/Notes/releases/download/nightly/TriliumNextNotes-develop-macos-x64.dmg", + arm64: "https://github.com/TriliumNext/Notes/releases/download/nightly/TriliumNextNotes-develop-macos-arm64.dmg" + }, + zip: { + name: "Portable (.zip)", + x64: "https://github.com/TriliumNext/Notes/releases/download/nightly/TriliumNextNotes-develop-macos-x64.zip", + arm64: "https://github.com/TriliumNext/Notes/releases/download/nightly/TriliumNextNotes-develop-macos-arm64.zip" + } + } + } + } +}; + +function getArchitecture(): Architecture { const userAgent = navigator.userAgent.toLowerCase(); - if (userAgent.includes('x86_64') || userAgent.includes('x64') || userAgent.includes('amd64')) { - return 'x64'; - } else if (userAgent.includes('arm64') || userAgent.includes('aarch64')) { + if (userAgent.includes('arm64') || userAgent.includes('aarch64')) { return 'arm64'; } + + return "x64"; } -function getPlatform() { +function getPlatform(): Platform { const userAgent = navigator.userAgent.toLowerCase(); if (userAgent.includes('macintosh') || userAgent.includes('mac os x')) { return "mac"; @@ -18,7 +86,7 @@ function getPlatform() { } } -function getDownloadLink(platform: string, architecture: string) { +function getDownloadLink(platform: Platform, architecture: Architecture) { const baseUrl = 'https://example.com/downloads'; let url; if (platform === 'mac') { @@ -41,9 +109,5 @@ function getDownloadLink(platform: string, architecture: string) { export function getRecommendedDownload() { const architecture = getArchitecture(); const platform = getPlatform(); - console.log(`Detected platform: ${platform}, architecture: ${architecture}`); - if (!architecture || !platform) { - return null; - } return getDownloadLink(platform, architecture); } diff --git a/apps/website/src/routes/download/+page.svelte b/apps/website/src/routes/download/+page.svelte index 3f148a0ca..89e7e7028 100644 --- a/apps/website/src/routes/download/+page.svelte +++ b/apps/website/src/routes/download/+page.svelte @@ -1,82 +1,52 @@ + +

Desktop application

+ +
+ Architecture: +
+ + +
+
+
- -
- Architecture: -
- - -
-
- + {#each Object.values(downloadMatrix.desktop) as platform}
-

Windows

- +

{platform.title}

-
-
- - - - + {/each}