Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

Landing: Download-pill size is auto-computed from the shipped shell

nyblnet97437dc24c4c
diff --git a/scripts/build-landing.mjs b/scripts/build-landing.mjs
index 10fa846f..91b73d5c 100644
--- a/scripts/build-landing.mjs
+++ b/scripts/build-landing.mjs
@@ -8,7 +8,7 @@
//
// node scripts/build-landing.mjs [outPath] (default: site/index.html)
-import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
+import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
@@ -38,7 +38,21 @@ for (const [ph, file] of [
['__PH_FAIRWIDE__', 'fairwide.jpg'],
]) html = html.replace(ph, thumb(file))
-if (/__(FRAUNCES|INSTRUMENT|PH_[A-Z0-9]+)__/.test(html)) {
+// Download-pill size claim: measured from the actual shell the download link
+// serves, so it can never drift from the real file. Prefer the released copy
+// (release.mjs writes it before calling this script); fall back to the local
+// build. Rounded to the nearest 10 KB to match the "~" approximate style.
+const shellFile = [
+ join(root, 'site/releases/slides/Bento_Slides.bento.html'),
+ join(root, 'slides/dist-single/Bento_Slides.bento.html'),
+].find(existsSync)
+if (!shellFile) {
+ throw new Error('no built shell found to size the Download pill — cut a release or run `npm run build:single` first')
+}
+const shellKB = Math.round(statSync(shellFile).size / 1024 / 10) * 10
+html = html.replace('__SHELL_KB__', String(shellKB))
+
+if (/__(FRAUNCES|INSTRUMENT|PH_[A-Z0-9]+|SHELL_KB)__/.test(html)) {
throw new Error('unreplaced placeholder in landing template')
}
diff --git a/site-src/landing.html b/site-src/landing.html
index ee5e001b..f3088d29 100644
--- a/site-src/landing.html
+++ b/site-src/landing.html
@@ -564,7 +564,7 @@ body.kdeck header, body.kdeck footer { display: none; }
<p class="sub rv in d1">Real <b>animation, video, live charts</b> and web-grade design, all in <b>one HTML file</b> that's the document, the editor and the player at once. Drop in a tired PowerPoint and let <b>AI rebuild it for the modern web</b>; perfect the details in the editor. No account, no cloud. <b>It saves itself.</b></p>
<div class="ctas rv in d2" style="margin-bottom:14px">
<a class="btn primary" href="/slides/">▶&nbsp; Try it in your browser</a>
- <a class="btn ghost-btn" href="/releases/slides/Bento_Slides.bento.html" download="Bento_Slides.bento.html">⤓&nbsp; Download <small class="dl-note">one file · ~530 KB</small></a>
+ <a class="btn ghost-btn" href="/releases/slides/Bento_Slides.bento.html" download="Bento_Slides.bento.html">⤓&nbsp; Download <small class="dl-note">one file · ~__SHELL_KB__ KB</small></a>
</div>
<div class="ctas rv in d3" style="margin:0 0 40px">
<a class="btn live" href="/guestbook/"><span class="pulse"></span><span class="gb-full">Join the public Guestbook</span><span class="gb-short">Guestbook</span><small class="gb-note" style="opacity:.85">· one live deck, everyone</small></a>