Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 30320f6

Browse files
committed
fix(website): download links for server
1 parent b58d0f6 commit 30320f6

3 files changed

Lines changed: 30 additions & 17 deletions

File tree

apps/website/src/lib/download-helper.ts

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
import rootPackageJson from '../../../../package.json';
22

3-
type App = "desktop" | "server";
3+
export type App = "desktop" | "server";
44

55
export type Architecture = 'x64' | 'arm64';
66

77
export type Platform = 'macos' | 'windows' | 'linux';
88

99
let version = rootPackageJson.version;
1010

11-
export function buildDesktopDownloadUrl(platform: Platform, format: string, architecture: Architecture): string {
12-
return `https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNextNotes-v${version}-${platform}-${architecture}.${format}`;
13-
}
14-
1511
export interface DownloadInfo {
1612
recommended?: boolean;
1713
name: string;
14+
url?: string;
1815
}
1916

2017
export interface DownloadMatrixEntry {
@@ -99,13 +96,16 @@ export const downloadMatrix: DownloadMatrix = {
9996
downloads: {
10097
docker: {
10198
recommended: true,
102-
name: "View on Docker Hub"
99+
name: "View on Docker Hub",
100+
url: "https://hub.docker.com/r/triliumnext/notes"
103101
},
104102
tarX64: {
105-
name: "x86 (.tar.xz)"
103+
name: "x86 (.tar.xz)",
104+
url: `https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNextNotes-Server-v${version}-linux-x64.tar.xz`
106105
},
107106
tarArm64: {
108-
name: "ARM (.tar.xz)"
107+
name: "ARM (.tar.xz)",
108+
url: `https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNextNotes-Server-v${version}-linux-arm64.tar.xz`
109109
},
110110
}
111111
},
@@ -115,16 +115,28 @@ export const downloadMatrix: DownloadMatrix = {
115115
downloads: {
116116
pikapod: {
117117
recommended: true,
118-
name: "Set up on PikaPods"
118+
name: "Set up on PikaPods",
119+
url: "https://www.pikapods.com/pods?run=trilium-next"
119120
},
120121
triliumcc: {
121-
name: "Alternatively see trilium.cc"
122+
name: "Alternatively see trilium.cc",
123+
url: "https://trilium.cc/"
122124
}
123125
}
124126
}
125127
}
126128
};
127129

130+
export function buildDownloadUrl(app: App, platform: Platform, format: string, architecture: Architecture): string {
131+
if (app === "desktop") {
132+
return `https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNextNotes-v${version}-${platform}-${architecture}.${format}`;
133+
} else if (app === "server") {
134+
return downloadMatrix.server[platform].downloads[format].url ?? "#";
135+
} else {
136+
return "#";
137+
}
138+
}
139+
128140
export function getArchitecture(): Architecture {
129141
const userAgent = navigator.userAgent.toLowerCase();
130142
if (userAgent.includes('arm64') || userAgent.includes('aarch64')) {
@@ -152,7 +164,7 @@ export function getRecommendedDownload() {
152164
const downloadInfo = downloadMatrix.desktop[platform]?.downloads;
153165
const recommendedDownload = Object.entries(downloadInfo || {}).find(d => d[1].recommended);
154166
const format = recommendedDownload?.[0];
155-
const url = buildDesktopDownloadUrl(platform, format || 'zip', architecture);
167+
const url = buildDownloadUrl("desktop", platform, format || 'zip', architecture);
156168

157169
return {
158170
architecture,

apps/website/src/routes/download/+page.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import type { Platform } from "$lib/download-helper";
3-
import { buildDesktopDownloadUrl, downloadMatrix, getArchitecture } from "$lib/download-helper";
3+
import { downloadMatrix, getArchitecture } from "$lib/download-helper";
44
import DownloadCard from "./download-card.svelte";
55
66
let architectures = ["x64", "arm64"] as const;
@@ -31,7 +31,7 @@
3131
{@const textColor = (platformId === "windows" ? "text-blue-600" : platformId === "linux" ? "text-violet-600" : "text-gray-800")}
3232
{@const bgColor = (platformId === "windows" ? "bg-blue-600" : platformId === "linux" ? "bg-violet-600" : "bg-gray-800")}
3333
{@const hoverColor = (platformId === "windows" ? "hover:bg-blue-700" : platformId === "linux" ? "hover:bg-violet-700" : "hover:bg-gray-900")}
34-
<DownloadCard
34+
<DownloadCard app="desktop"
3535
{textColor} {bgColor} {hoverColor}
3636
{platform} {architecture} platformId={platformId as Platform} />
3737
{/each}
@@ -46,7 +46,7 @@
4646
{@const textColor = (platformId === "linux" ? "text-violet-600" : "text-gray-800")}
4747
{@const bgColor = (platformId === "linux" ? "bg-violet-600" : "bg-gray-800")}
4848
{@const hoverColor = (platformId === "linux" ? "hover:bg-violet-700" : "hover:bg-gray-900")}
49-
<DownloadCard
49+
<DownloadCard app="server"
5050
{textColor} {bgColor} {hoverColor}
5151
{platform} {architecture} platformId={platformId as Platform} />
5252
{/each}

apps/website/src/routes/download/download-card.svelte

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
2-
import { buildDesktopDownloadUrl, type Architecture, type DownloadMatrixEntry, type Platform } from "$lib/download-helper";
2+
import { buildDownloadUrl, type Architecture, type DownloadMatrixEntry, type Platform, type App } from "$lib/download-helper";
33
4+
export let app: App = "desktop";
45
export let platformId: Platform;
56
export let platform: DownloadMatrixEntry;
67
export let textColor: string;
@@ -15,13 +16,13 @@
1516
<p class="text-gray-700 mb-12">{typeof platform.title === "object" ? platform.description[architecture] : platform.description}</p>
1617
<div class="space-y-2 mt-auto w-full">
1718
{#if recommended}
18-
<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">
19+
<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">
1920
{recommended[1].name}
2021
</a>
2122
{/if}
2223
<div class="flex justify-center gap-4 text-sm {textColor} mt-2">
2324
{#each Object.entries(platform.downloads).filter((e) => !e[1].recommended) as [format, download]}
24-
<a href={buildDesktopDownloadUrl(platformId as Platform, format, architecture)} class="hover:underline block">
25+
<a href={buildDownloadUrl(app, platformId as Platform, format, architecture)} class="hover:underline block">
2526
{download.name}
2627
</a>
2728
{/each}

0 commit comments

Comments
 (0)