Anchor the gallery's assets to the tree, not to the page directory
Some checks are pending
build-gate / build (push) Waiting to run
Some checks are pending
build-gate / build (push) Waiting to run
The archived gallery resolved ASSETS as BASE + 'assets' — this PAGE's own
directory. That was correct only while the gallery WAS the root page, where the
two coincide. Since it moved to /__gallery it asked for /__gallery/assets/...
Measured on the built tree with the page at /__gallery/:
/__gallery/assets/vendor/vue/vue.global.prod.js ... 404
/doxa-maps/assets/vendor/vue/vue.global.prod.js ... 200
Every leaf page already agrees where assets live: a leaf at
/<tree>/<bundle>/<profile>/ bakes assetsBase "../../assets" -> /<tree>/assets.
So anchor to the tree root, which TREE_URL already names.
This degraded QUIETLY rather than blanking, which is why it outlived the move:
loadVue() falls back to the jsDelivr CDN, so the page kept working while
silently losing the portable / offline / no-CDN property the vendored copy
exists to provide. After the fix the built page loads Vue from
/doxa-maps/assets/vendor/vue/ and reports zero 4xx/5xx.
TREE_URL moves above ASSETS because ASSETS now depends on it; both are `var`,
so the old order would have yielded the string "undefined/assets" rather than
an error. Its explanatory comment moves with the declaration.
The dev server passes assetsBaseUrl explicitly, so this is the built-tree half
of the fix its comment already documents for dev.
This commit is contained in:
parent
04eccdfa7a
commit
d4ab3a8e09
2 changed files with 63 additions and 11 deletions
|
|
@ -374,13 +374,6 @@ ${dev ? LADDER_CSS : ''}</style>
|
|||
var p = location.pathname || '/';
|
||||
return /\.[a-z0-9]+$/i.test(p) ? p.replace(/[^/]*$/, '') : p.replace(/\/*$/, '') + '/';
|
||||
})();
|
||||
var ASSETS = ASSETS_BASE || new URL(BASE + 'assets', location.origin).href.replace(/\/+$/, '');
|
||||
var REG = BAKED, active = null, seq = 0, loaded = {}, fetchedToken = '';
|
||||
var narrow = function () { return window.matchMedia && window.matchMedia('(max-width:700px)').matches };
|
||||
|
||||
// Manifest refs are relative to the tree root; this page sits one level above it. Refs are
|
||||
// anchored to BASE (above) so they resolve the same with or without a trailing slash.
|
||||
function rel(u) { return /^([a-z]+:|\/)/i.test(u) ? u : BASE + TREE + '/' + u.replace(/^\.\//, '') }
|
||||
// ★ THE TREE ROOT AS ONE ABSOLUTE URL — derive it ONCE, never re-join TREE by hand.
|
||||
// TREE is PAGE-RELATIVE and its value differs per surface ('../doxa-maps' in the built tree,
|
||||
// '__plugin-gallery' in dev), so a bare TREE + '/x' join is only accidentally right. It was right
|
||||
|
|
@ -397,6 +390,25 @@ ${dev ? LADDER_CSS : ''}</style>
|
|||
// the base URL lets the URL parser apply the right rule per shape: a rooted TREE replaces the
|
||||
// path, a '../' TREE climbs out of /__gallery/, and a bare name resolves beside it.
|
||||
var TREE_URL = new URL(TREE, new URL(BASE, location.href)).href.replace(/\/+$/, '');
|
||||
// ASSETS live INSIDE the tree (public/<tree>/assets), which is what every leaf page points at:
|
||||
// a leaf at /<tree>/<bundle>/<profile>/ bakes assetsBase "../../assets" -> /<tree>/assets. So
|
||||
// anchor to TREE_URL, not to this PAGE's directory.
|
||||
// This was BASE + 'assets' — correct only while the gallery WAS the root page, where the two
|
||||
// coincide. Since the gallery moved to /__gallery it asked for /__gallery/assets/... MEASURED
|
||||
// on the built tree with the page at /__gallery/:
|
||||
// /__gallery/assets/vendor/vue/vue.global.prod.js ... 404 (what the page asked for)
|
||||
// /doxa-maps/assets/vendor/vue/vue.global.prod.js ... 200 (where it lives)
|
||||
// It degraded quietly rather than blanking — loadVue() falls back to the jsDelivr CDN — so the
|
||||
// page still worked while silently losing the portable/offline/no-CDN property the vendored
|
||||
// copy exists to provide. The dev server passes assetsBaseUrl explicitly, so this is the
|
||||
// built-tree half of the same fix its comment already documents.
|
||||
var ASSETS = ASSETS_BASE || TREE_URL + '/assets';
|
||||
var REG = BAKED, active = null, seq = 0, loaded = {}, fetchedToken = '';
|
||||
var narrow = function () { return window.matchMedia && window.matchMedia('(max-width:700px)').matches };
|
||||
|
||||
// Manifest refs are relative to the tree root; this page sits one level above it. Refs are
|
||||
// anchored to BASE (above) so they resolve the same with or without a trailing slash.
|
||||
function rel(u) { return /^([a-z]+:|\/)/i.test(u) ? u : BASE + TREE + '/' + u.replace(/^\.\//, '') }
|
||||
function qp(name) { try { return new URLSearchParams(location.search).get(name) || '' } catch (e) { return '' } }
|
||||
function hint(msg, err) { var slot = slotEl(); var d = document.createElement('div'); d.className = 'hint' + (err ? ' err' : ''); d.textContent = msg; slot.innerHTML = ''; slot.appendChild(d); return d }
|
||||
function assign(t) { for (var i = 1; i < arguments.length; i++) { var s = arguments[i]; for (var k in s) if (Object.prototype.hasOwnProperty.call(s, k)) t[k] = s[k] } return t }
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue