refactor(website): improve types

This commit is contained in:
Elian Doran 2025-06-14 16:40:50 +03:00
parent be7fe9610f
commit f0ce728982
No known key found for this signature in database
2 changed files with 12 additions and 2 deletions

View File

@ -1,5 +1,7 @@
import rootPackageJson from '../../../../package.json';
type App = "desktop";
export type Architecture = 'x64' | 'arm64';
export type Platform = 'mac' | 'windows' | 'linux';
@ -10,8 +12,16 @@ export function buildDesktopDownloadUrl(platform: Platform, format: string, arch
return `https://github.com/TriliumNext/Notes/releases/download/${version}/TriliumNextNotes-${version}-${platform}-${architecture}.${format}`;
}
interface DownloadMatrixEntry {
title: Record<Architecture, string>;
description: Record<Architecture, string>;
downloads: Record<string, { recommended?: boolean; name: string }>;
}
type DownloadMatrix = Record<App, Record<Platform, DownloadMatrixEntry>>;
// Keep compatibility info inline with https://github.com/electron/electron/blob/main/README.md#platform-support.
export const downloadMatrix = {
export const downloadMatrix: DownloadMatrix = {
desktop: {
windows: {
title: {

View File

@ -2,7 +2,7 @@
import type { Platform } from "$lib/download-helper";
import { buildDesktopDownloadUrl, downloadMatrix, getArchitecture } from "$lib/download-helper";
let architectures = ["x64", "arm64"];
let architectures = ["x64", "arm64"] as const;
let architecture = getArchitecture();
</script>