Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(site): the download labels come from the build, not from a blocked request

yhhb51600cf8899
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index ce15e703b..2cc1a19fe 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -59,6 +59,12 @@ jobs:
# page's fonts and mark now, and a copy step that has to be edited when
# the page grows an asset is a broken page waiting to be deployed.
cp -r docs/landing/. docs/dist/
+
+ # The page states the version it was built from, so the download
+ # section is labelled with no JavaScript and no cross-origin request.
+ # The links themselves are the mirror's stable `latest/` names, which
+ # stay correct for releases published after this deploy.
+ sed -i "s/__ESTELLA_VERSION__/$(node -p "require('./desktop/package.json').version")/g" docs/dist/index.html
echo 'estellaengine.com' > docs/dist/CNAME
touch docs/dist/.nojekyll
diff --git a/docs/build.ps1 b/docs/build.ps1
index aa6583e03..8880d5a61 100644
--- a/docs/build.ps1
+++ b/docs/build.ps1
@@ -110,6 +110,15 @@ function Merge-Output {
# does not exist.
if (Test-Path "$DocsRoot\landing") {
Copy-Item -Recurse "$DocsRoot\landing\*" $OutputDir
+ # The page states the version it was built from — see docs.yml. Read and
+ # written as UTF-8 through .NET: Get-Content/Set-Content on this host
+ # decode as the ANSI codepage, which turns every non-ASCII character in
+ # the page (the 中文 link, the arrows) into mojibake on the way through.
+ $version = (Get-Content "$DocsRoot\..\desktop\package.json" -Raw | ConvertFrom-Json).version
+ $index = "$OutputDir\index.html"
+ $utf8 = New-Object System.Text.UTF8Encoding($false)
+ $html = [System.IO.File]::ReadAllText($index, $utf8)
+ [System.IO.File]::WriteAllText($index, $html.Replace('__ESTELLA_VERSION__', $version), $utf8)
}
# Copy Astro output
diff --git a/docs/build.sh b/docs/build.sh
index 842e14be2..ce508246e 100644
--- a/docs/build.sh
+++ b/docs/build.sh
@@ -96,6 +96,9 @@ merge_output() {
# does not exist.
if [ -d "$DOCS_ROOT/landing" ]; then
cp -r "$DOCS_ROOT/landing/." "$OUTPUT_DIR/"
+ # The page states the version it was built from — see docs.yml.
+ version=$(node -p "require('$DOCS_ROOT/../desktop/package.json').version")
+ sed -i "s/__ESTELLA_VERSION__/$version/g" "$OUTPUT_DIR/index.html"
fi
# Copy Astro output
diff --git a/docs/landing/index.html b/docs/landing/index.html
index 4bb7485ab..439c0bc2a 100644
--- a/docs/landing/index.html
+++ b/docs/landing/index.html
@@ -296,15 +296,6 @@
.dl-foot p { margin: 8px 0 0; }
.dl-foot .warnmark { color: var(--sel); }
- /* skeleton while the mirror is being asked */
- .meta[data-loading] .size {
- display: inline-block; width: 62px; height: 9px; vertical-align: middle;
- border-radius: 999px; background: var(--srf-4);
- animation: pulse 1.4s var(--e-out) infinite;
- }
- .meta[data-loading] .size::after { content: none; }
- @keyframes pulse { 50% { opacity: 0.45; } }
-
/* ── features ───────────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.card {
@@ -420,9 +411,13 @@
<path d="M42 42 L50 50 L58 42" fill="none" stroke="#9fd2f7" stroke-width="0.7" opacity="0.6" />
</svg>
- <a class="chip" id="release-chip" href="https://github.com/esengine/estella/releases">
+ <!-- The version token below is substituted when the site is merged
+ (docs.yml, build.sh, build.ps1) from desktop/package.json, the one
+ place the app version lives. The mirror refreshes it at runtime when
+ it is allowed to answer. -->
+ <a class="chip" id="release-chip" href="https://github.com/esengine/estella/releases/tag/v__ESTELLA_VERSION__">
<span class="dot" aria-hidden="true"></span>
- <span id="release-label">Latest release</span>
+ <span id="release-label">v__ESTELLA_VERSION__</span>
<span class="sep">·</span>
<span>changelog</span>
</a>
@@ -481,7 +476,7 @@
<a class="btn primary" id="btn-win" href="https://dl.estella.games/latest/Estella-Editor-Setup.exe" download>
Download for Windows
</a>
- <div class="meta" id="meta-win" data-loading><span class="size"></span><span class="name">Estella-Editor-Setup.exe</span></div>
+ <div class="meta" id="meta-win"><span class="size"></span><span class="name">Estella-Editor-Setup-__ESTELLA_VERSION__.exe</span></div>
</div>
<div class="dl-card" id="card-mac">
@@ -493,7 +488,7 @@
<a class="btn primary" id="btn-mac" href="https://dl.estella.games/latest/Estella-Editor-arm64.dmg" download>
Download for macOS
</a>
- <div class="meta" id="meta-mac" data-loading><span class="size"></span><span class="name">Estella-Editor-arm64.dmg</span></div>
+ <div class="meta" id="meta-mac"><span class="size"></span><span class="name">Estella-Editor-__ESTELLA_VERSION__-arm64.dmg</span></div>
</div>
</div>
@@ -618,12 +613,27 @@
</footer>
<script>
- // Progressive enhancement only. The download buttons already point at stable
- // mirror aliases that always resolve to the newest release, so everything
- // below is decoration: which card is yours, and what you are about to get.
+ // Progressive enhancement only. The download buttons point at stable mirror
+ // aliases that always resolve to the newest release, and the version beside
+ // them is substituted when the site is built — so everything below is a
+ // refinement: which card is yours, and the exact size and name of the file
+ // if the mirror can be asked. It cannot be, from a browser, until the bucket
+ // states a CORS rule; the page is written to not care either way.
(function () {
var MIRROR = 'https://dl.estella.games/latest.json';
+ // Opened as a file rather than through the site build: show nothing rather
+ // than the placeholder the build would have replaced.
+ var label = document.getElementById('release-label');
+ if (label.textContent.indexOf('__') >= 0) {
+ label.textContent = 'Latest release';
+ document.getElementById('release-chip').href =
+ 'https://github.com/esengine/estella/releases';
+ [].forEach.call(document.querySelectorAll('.meta .name'), function (el) {
+ if (el.textContent.indexOf('__') >= 0) el.textContent = '';
+ });
+ }
+
function detectOS() {
var ua = navigator.userAgent;
if (/Mac|iPhone|iPad/.test(ua)) return 'mac';
@@ -666,17 +676,12 @@
[['win', d.win], ['mac', d['mac-arm64']]].forEach(function (pair) {
var meta = document.getElementById('meta-' + pair[0]);
var info = pair[1];
- meta.removeAttribute('data-loading');
if (!info) return;
if (info.size) meta.querySelector('.size').textContent = mb(info.size);
if (info.name) meta.querySelector('.name').textContent = info.name;
});
})
- .catch(function () {
- ['meta-win', 'meta-mac'].forEach(function (id) {
- document.getElementById(id).removeAttribute('data-loading');
- });
- });
+ .catch(function () { /* the built-in labels stand */ });
})();
</script>
</body>