fix(site): use latest downloads with simpler labels (#398)
Both platform download routes now follow the provider's native latest attachment: GitHub uses `releases/latest/download/…` and Gitee uses `releases/download/latest/…`. Publishing a mirrored package no longer requires rebuilding the website to refresh a version-specific URL. Remove the build-time release API calls, metadata adapter and its obsolete tests. The main buttons read “Download” / “下载”, with “Download via Gitee” / “Gitee 备用下载” for the alternative. The film's homepage demonstration inherits the same links and copy. The website guide documents the routes and the possible delay between primary publication and mirror completion. Validation: website build and TypeScript checks; six generated latest links checked in the homepage and film demonstration; all three real Gitee latest downloads matched the GitHub package sizes and SHA-256 checksums. The release planner reports `publish: false`.
This commit is contained in:
7 files changed
+39
-193
No files matched your search
@@ -34,22 +34,8 @@ const welcomeLines = WELCOME_LINES.map(({ key }) => renderToStaticMarkup(
|
||||
createElement("span", { lang: "zh-CN" }, `“${locales.zh.copy[key]}”`),
|
||||
),
|
||||
));
|
||||
let homepage = (await readFile(new URL("index.html", source), "utf8"))
|
||||
const homepage = (await readFile(new URL("index.html", source), "utf8"))
|
||||
.replace(/<p id="welcome-line">.*?<\/p>/, `<p id="welcome-line">${welcomeLines[0]}</p>`);
|
||||
if (process.env.PIIK_WEBSITE_RELEASE_DATA) {
|
||||
const { websiteDownloads } = await tsImport("../site/downloads.ts", { parentURL: import.meta.url });
|
||||
const release = websiteDownloads(JSON.parse(await readFile(process.env.PIIK_WEBSITE_RELEASE_DATA, "utf8")));
|
||||
homepage = homepage.replace(/<a\b([^>]*data-download="([^"]+)"[^>]*data-provider="([^"]+)"[^>]*)>([\s\S]*?)<\/a\s*>/g,
|
||||
(original, attributes, target, provider, content) => {
|
||||
const item = release.packages.find(item => item.target === target);
|
||||
const href = provider === 'github' ? item?.url : item?.mirrorURL;
|
||||
if (!href) return original;
|
||||
if (provider === 'gitee') content = content
|
||||
.replace(/<span lang="en">[\s\S]*?<\/span\s*>/, '<span lang="en">Gitee alternative · ZIP</span>')
|
||||
.replace(/<span lang="zh-CN">[\s\S]*?<\/span\s*>/, '<span lang="zh-CN">Gitee 备用 · ZIP</span>');
|
||||
return `<a${attributes.replace(/href="[^"]*"/, `href="${href}"`)}>${content}</a>`;
|
||||
});
|
||||
}
|
||||
await writeFile(new URL("index.html", output), homepage.replace(
|
||||
'</body>', `<template id="welcome-lines">${welcomeLines.join('')}</template></body>`,
|
||||
));
|
||||
|
||||
Reference in new issue
Block a user