Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(website): download links for server
Elian Doran30320f6d8401
diff --git a/apps/website/src/lib/download-helper.ts b/apps/website/src/lib/download-helper.tsindex 61b6e7ef9e..0dc8d8d6a0 100644--- a/apps/website/src/lib/download-helper.ts+++ b/apps/website/src/lib/download-helper.ts@@ -1,6 +1,6 @@import rootPackageJson from '../../../../package.json';-type App = "desktop" | "server";+export type App = "desktop" | "server";export type Architecture = 'x64' | 'arm64';@@ -8,13 +8,10 @@ export type Platform = 'macos' | 'windows' | 'linux';let version = rootPackageJson.version;-export function buildDesktopDownloadUrl(platform: Platform, format: string, architecture: Architecture): string {- return `https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNextNotes-v${version}-${platform}-${architecture}.${format}`;-}-export interface DownloadInfo {recommended?: boolean;name: string;+ url?: string;}export interface DownloadMatrixEntry {@@ -99,13 +96,16 @@ export const downloadMatrix: DownloadMatrix = {downloads: {docker: {recommended: true,- name: "View on Docker Hub"+ name: "View on Docker Hub",+ url: "https://hub.docker.com/r/triliumnext/notes"},tarX64: {- name: "x86 (.tar.xz)"+ name: "x86 (.tar.xz)",+ url: `https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNextNotes-Server-v${version}-linux-x64.tar.xz`},tarArm64: {- name: "ARM (.tar.xz)"+ name: "ARM (.tar.xz)",+ url: `https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNextNotes-Server-v${version}-linux-arm64.tar.xz`},}},@@ -115,16 +115,28 @@ export const downloadMatrix: DownloadMatrix = {downloads: {pikapod: {recommended: true,- name: "Set up on PikaPods"+ name: "Set up on PikaPods",+ url: "https://www.pikapods.com/pods?run=trilium-next"},triliumcc: {- name: "Alternatively see trilium.cc"+ name: "Alternatively see trilium.cc",+ url: "https://trilium.cc/"}}}}};+export function buildDownloadUrl(app: App, platform: Platform, format: string, architecture: Architecture): string {+ if (app === "desktop") {+ return `https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNextNotes-v${version}-${platform}-${architecture}.${format}`;+ } else if (app === "server") {+ return downloadMatrix.server[platform].downloads[format].url ?? "#";+ } else {+ return "#";+ }+}+export function getArchitecture(): Architecture {const userAgent = navigator.userAgent.toLowerCase();if (userAgent.includes('arm64') || userAgent.includes('aarch64')) {@@ -152,7 +164,7 @@ export function getRecommendedDownload() {const downloadInfo = downloadMatrix.desktop[platform]?.downloads;const recommendedDownload = Object.entries(downloadInfo || {}).find(d => d[1].recommended);const format = recommendedDownload?.[0];- const url = buildDesktopDownloadUrl(platform, format || 'zip', architecture);+ const url = buildDownloadUrl("desktop", platform, format || 'zip', architecture);return {architecture,diff --git a/apps/website/src/routes/download/+page.svelte b/apps/website/src/routes/download/+page.svelteindex 5ed060a8fa..aea89d9058 100644--- a/apps/website/src/routes/download/+page.svelte+++ b/apps/website/src/routes/download/+page.svelte@@ -1,6 +1,6 @@<script lang="ts">import type { Platform } from "$lib/download-helper";- import { buildDesktopDownloadUrl, downloadMatrix, getArchitecture } from "$lib/download-helper";+ import { downloadMatrix, getArchitecture } from "$lib/download-helper";import DownloadCard from "./download-card.svelte";let architectures = ["x64", "arm64"] as const;@@ -31,7 +31,7 @@{@const textColor = (platformId === "windows" ? "text-blue-600" : platformId === "linux" ? "text-violet-600" : "text-gray-800")}{@const bgColor = (platformId === "windows" ? "bg-blue-600" : platformId === "linux" ? "bg-violet-600" : "bg-gray-800")}{@const hoverColor = (platformId === "windows" ? "hover:bg-blue-700" : platformId === "linux" ? "hover:bg-violet-700" : "hover:bg-gray-900")}- <DownloadCard+ <DownloadCard app="desktop"{textColor} {bgColor} {hoverColor}{platform} {architecture} platformId={platformId as Platform} />{/each}@@ -46,7 +46,7 @@{@const textColor = (platformId === "linux" ? "text-violet-600" : "text-gray-800")}{@const bgColor = (platformId === "linux" ? "bg-violet-600" : "bg-gray-800")}{@const hoverColor = (platformId === "linux" ? "hover:bg-violet-700" : "hover:bg-gray-900")}- <DownloadCard+ <DownloadCard app="server"{textColor} {bgColor} {hoverColor}{platform} {architecture} platformId={platformId as Platform} />{/each}diff --git a/apps/website/src/routes/download/download-card.svelte b/apps/website/src/routes/download/download-card.svelteindex 6188671d3d..c2423505dc 100644--- a/apps/website/src/routes/download/download-card.svelte+++ b/apps/website/src/routes/download/download-card.svelte@@ -1,6 +1,7 @@<script lang="ts">- import { buildDesktopDownloadUrl, type Architecture, type DownloadMatrixEntry, type Platform } from "$lib/download-helper";+ import { buildDownloadUrl, type Architecture, type DownloadMatrixEntry, type Platform, type App } from "$lib/download-helper";+ export let app: App = "desktop";export let platformId: Platform;export let platform: DownloadMatrixEntry;export let textColor: string;@@ -15,13 +16,13 @@<p class="text-gray-700 mb-12">{typeof platform.title === "object" ? platform.description[architecture] : platform.description}</p><div class="space-y-2 mt-auto w-full">{#if recommended}- <a href={buildDesktopDownloadUrl(platformId as Platform, recommended[0], architecture)} class="mt-auto block text-center {bgColor} {hoverColor} text-white font-medium py-2 px-5 rounded-full shadow transition">+ <a href={buildDownloadUrl(app, platformId as Platform, recommended[0], architecture)} class="mt-auto block text-center {bgColor} {hoverColor} text-white font-medium py-2 px-5 rounded-full shadow transition">{recommended[1].name}</a>{/if}<div class="flex justify-center gap-4 text-sm {textColor} mt-2">{#each Object.entries(platform.downloads).filter((e) => !e[1].recommended) as [format, download]}- <a href={buildDesktopDownloadUrl(platformId as Platform, format, architecture)} class="hover:underline block">+ <a href={buildDownloadUrl(app, platformId as Platform, format, architecture)} class="hover:underline block">{download.name}</a>{/each}