import { Request } from "express"; import { AppMeta } from "./paths.js"; /** * One landing page per app. Each platform that has a file gets its own * button — an app published for iOS and Android must not hide one behind the * other, which is what happened when the page branched on `meta.platform` * (the platform of the most recent publish). */ export function renderLanding(req: Request, slug: string, meta: AppMeta): string { const proto = (req.headers["x-forwarded-proto"] as string | undefined) ?? req.protocol; const host = req.headers.host ?? "localhost"; const base = `${proto}://${host}`; const buttons: string[] = []; const notes: string[] = []; if (meta.ipaFile) { const manifestUrl = `${base}/install/${slug}/manifest.plist`; const itmsUrl = `itms-services://?action=download-manifest&url=${encodeURIComponent(manifestUrl)}`; buttons.push(`Install on iOS`); notes.push("iOS: ad-hoc build — your device UDID must be in the provisioning profile."); } if (meta.apkFile) { const apkUrl = `${base}/install/${slug}/${meta.apkFile}`; buttons.push(`Download APK`); notes.push('Android: enable "Install unknown apps" in settings before installing.'); } return `
Version ${meta.version}
${meta.icon ? `
${notes.join("
")}