mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
fix(website): download links for server
This commit is contained in:
parent
b58d0f6663
commit
30320f6d84
@ -1,6 +1,6 @@
|
|||||||
import rootPackageJson from '../../../../package.json';
|
import rootPackageJson from '../../../../package.json';
|
||||||
|
|
||||||
type App = "desktop" | "server";
|
export type App = "desktop" | "server";
|
||||||
|
|
||||||
export type Architecture = 'x64' | 'arm64';
|
export type Architecture = 'x64' | 'arm64';
|
||||||
|
|
||||||
@ -8,13 +8,10 @@ export type Platform = 'macos' | 'windows' | 'linux';
|
|||||||
|
|
||||||
let version = rootPackageJson.version;
|
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 {
|
export interface DownloadInfo {
|
||||||
recommended?: boolean;
|
recommended?: boolean;
|
||||||
name: string;
|
name: string;
|
||||||
|
url?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DownloadMatrixEntry {
|
export interface DownloadMatrixEntry {
|
||||||
@ -99,13 +96,16 @@ export const downloadMatrix: DownloadMatrix = {
|
|||||||
downloads: {
|
downloads: {
|
||||||
docker: {
|
docker: {
|
||||||
recommended: true,
|
recommended: true,
|
||||||
name: "View on Docker Hub"
|
name: "View on Docker Hub",
|
||||||
|
url: "https://hub.docker.com/r/triliumnext/notes"
|
||||||
},
|
},
|
||||||
tarX64: {
|
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: {
|
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: {
|
downloads: {
|
||||||
pikapod: {
|
pikapod: {
|
||||||
recommended: true,
|
recommended: true,
|
||||||
name: "Set up on PikaPods"
|
name: "Set up on PikaPods",
|
||||||
|
url: "https://www.pikapods.com/pods?run=trilium-next"
|
||||||
},
|
},
|
||||||
triliumcc: {
|
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 {
|
export function getArchitecture(): Architecture {
|
||||||
const userAgent = navigator.userAgent.toLowerCase();
|
const userAgent = navigator.userAgent.toLowerCase();
|
||||||
if (userAgent.includes('arm64') || userAgent.includes('aarch64')) {
|
if (userAgent.includes('arm64') || userAgent.includes('aarch64')) {
|
||||||
@ -152,7 +164,7 @@ export function getRecommendedDownload() {
|
|||||||
const downloadInfo = downloadMatrix.desktop[platform]?.downloads;
|
const downloadInfo = downloadMatrix.desktop[platform]?.downloads;
|
||||||
const recommendedDownload = Object.entries(downloadInfo || {}).find(d => d[1].recommended);
|
const recommendedDownload = Object.entries(downloadInfo || {}).find(d => d[1].recommended);
|
||||||
const format = recommendedDownload?.[0];
|
const format = recommendedDownload?.[0];
|
||||||
const url = buildDesktopDownloadUrl(platform, format || 'zip', architecture);
|
const url = buildDownloadUrl("desktop", platform, format || 'zip', architecture);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
architecture,
|
architecture,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Platform } from "$lib/download-helper";
|
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";
|
import DownloadCard from "./download-card.svelte";
|
||||||
|
|
||||||
let architectures = ["x64", "arm64"] as const;
|
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 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 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")}
|
{@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}
|
{textColor} {bgColor} {hoverColor}
|
||||||
{platform} {architecture} platformId={platformId as Platform} />
|
{platform} {architecture} platformId={platformId as Platform} />
|
||||||
{/each}
|
{/each}
|
||||||
@ -46,7 +46,7 @@
|
|||||||
{@const textColor = (platformId === "linux" ? "text-violet-600" : "text-gray-800")}
|
{@const textColor = (platformId === "linux" ? "text-violet-600" : "text-gray-800")}
|
||||||
{@const bgColor = (platformId === "linux" ? "bg-violet-600" : "bg-gray-800")}
|
{@const bgColor = (platformId === "linux" ? "bg-violet-600" : "bg-gray-800")}
|
||||||
{@const hoverColor = (platformId === "linux" ? "hover:bg-violet-700" : "hover:bg-gray-900")}
|
{@const hoverColor = (platformId === "linux" ? "hover:bg-violet-700" : "hover:bg-gray-900")}
|
||||||
<DownloadCard
|
<DownloadCard app="server"
|
||||||
{textColor} {bgColor} {hoverColor}
|
{textColor} {bgColor} {hoverColor}
|
||||||
{platform} {architecture} platformId={platformId as Platform} />
|
{platform} {architecture} platformId={platformId as Platform} />
|
||||||
{/each}
|
{/each}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<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 platformId: Platform;
|
||||||
export let platform: DownloadMatrixEntry;
|
export let platform: DownloadMatrixEntry;
|
||||||
export let textColor: string;
|
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>
|
<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">
|
<div class="space-y-2 mt-auto w-full">
|
||||||
{#if recommended}
|
{#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}
|
{recommended[1].name}
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="flex justify-center gap-4 text-sm {textColor} mt-2">
|
<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]}
|
{#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}
|
{download.name}
|
||||||
</a>
|
</a>
|
||||||
{/each}
|
{/each}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user