Files
remark42/site/package.json
T
Dmitry Verkhoturov f4ac5bcea2 site: fetch latest version client-side instead of embedding at build time
The header version badge was filled in by site/src/data/github.js calling
the GitHub releases API at Eleventy build time and baking data[0].tag_name
into every page. This had three failure modes:

1. Layered cache: Buildx caches the yarn build layer; on a release-triggered
   workflow nothing under ./site changes, so the cached HTML (with the
   previous tag baked in) gets shipped. v1.16.0 went out and remark42.com
   kept showing v1.15.0 until a separate site/ commit landed and naturally
   invalidated the COPY layer.

2. Tag mismatch: the deploy pulls ghcr.io/umputun/remark42-site:master,
   but release events build :v1.16.0 and :latest only. A cache-skip
   workflow tweak wouldn't even reach the served image.

3. API propagation race: the workflow fires ~2s after release publish,
   so even with cache disabled the API might still return the previous
   tag from a stale read replica.

All three vanish if the version is fetched in the browser. GitHub serves
the /releases/latest response with Cache-Control: public, max-age=60 so
per-visitor cost is bounded; failures fall through silently and the
badge stays empty rather than wrong.

Changes:
- header.njk: replace {{ github.latestVersion }} with a
  <span data-remark42-version></span> placeholder.
- inline.js: add a fetch of /releases/latest that fills any
  [data-remark42-version] element on the page. fallback is no-op on any
  network/parse failure.
- delete site/src/data/github.js (Eleventy data file is no longer used).
- drop node-fetch from devDependencies (was used only by github.js).
2026-05-26 20:58:00 +01:00

39 lines
1.2 KiB
JSON

{
"name": "remark42-site",
"version": "0.0.0",
"repository": "https://github.com/umputun/remark42/site",
"homepage": "https://remark42.com",
"author": "Pavel Mineev <pavel@mineev.me>",
"license": "MIT",
"private": true,
"engines": {
"node": ">=20.11.1",
"yarn": ">=1.22"
},
"packageManager": "yarn@1.22.22",
"scripts": {
"start": "npm-run-all dev",
"dev": "npm-run-all -l clean build:css -p dev:css dev:11ty",
"dev:css": "tailwindcss -i ./src/styles.css -o .tmp/style.css -w",
"dev:11ty": "eleventy --serve --watch --quiet",
"build": "cross-env NODE_ENV=production run-s clean build:css build:11ty --print-label",
"build:css": "tailwindcss -i ./src/styles.css -o .tmp/style.css",
"build:11ty": "eleventy",
"clean": "rm -rf .tmp/* build/*"
},
"devDependencies": {
"@11ty/eleventy": "^2.0.1",
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
"@tailwindcss/typography": "^0.5.15",
"cross-env": "^7.0.3",
"date-fns": "^4.1.0",
"html-minifier": "^4.0.0",
"markdown-it": "^14.0.0",
"markdown-it-anchor": "^9.2.0",
"markdown-it-container": "^4.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.4.1",
"tailwindcss": "^3.4.15"
}
}