@tideworthy/tidysites-platform 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/editor/revisions.ts +7 -2
- package/src/routes/revisions.ts +5 -1
- package/src/version.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tideworthy/tidysites-platform",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "The Tidysites platform integration for EmDash sites: bootstrap, sessions, maintenance, health, and publish hooks under /_tidy/*.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/editor/revisions.ts
CHANGED
|
@@ -100,9 +100,14 @@ export function startRevisions(): void {
|
|
|
100
100
|
const j = (await r.json().catch(() => ({}))) as { error?: string };
|
|
101
101
|
frame.srcdoc = `<p style="font:15px system-ui;margin:2rem">${j.error ?? "This revision could not be read."}</p>`;
|
|
102
102
|
} else {
|
|
103
|
-
// The stored copy links its assets by absolute path;
|
|
103
|
+
// The stored copy links its built assets by absolute path (/_astro/...);
|
|
104
|
+
// those are read from the revision itself, so the page shows the way it
|
|
105
|
+
// was built. Everything else (uploads, links) resolves against this site.
|
|
104
106
|
const html = await r.text();
|
|
105
|
-
|
|
107
|
+
const own = (p: string) => `${ROUTE}?id=${encodeURIComponent(rev.id)}&path=${encodeURIComponent(p)}`;
|
|
108
|
+
frame.srcdoc = html
|
|
109
|
+
.replace(/(href|src)="(\/_astro\/[^"]+)"/g, (_m, attr: string, p: string) => `${attr}="${own(p)}"`)
|
|
110
|
+
.replace(/<head([^>]*)>/i, `<head$1><base href="${location.origin}/"><style>html.tidy-has-bar body{padding-top:0!important}#tidy-bar,.tidy-bar{display:none!important}</style>`);
|
|
106
111
|
}
|
|
107
112
|
viewer.hidden = false;
|
|
108
113
|
restoreBtn.onclick = async () => {
|
package/src/routes/revisions.ts
CHANGED
|
@@ -47,7 +47,11 @@ export const GET: APIRoute = async (context) => {
|
|
|
47
47
|
if (!/^[0-9a-f-]{36}$/i.test(id)) return json({ error: "bad revision id" }, 400);
|
|
48
48
|
const r = await c.call(`/releases/${id}/page?path=${encodeURIComponent(path)}`);
|
|
49
49
|
if (!r.ok) return json({ error: r.status === 404 ? "That page was not in this revision." : "The revision could not be read." }, r.status === 404 ? 404 : 502);
|
|
50
|
-
|
|
50
|
+
// A page comes back as HTML; a path with an extension is one of the
|
|
51
|
+
// revision's own files (its stylesheets, scripts, images), passed through
|
|
52
|
+
// with its type so the page shows the way it was built.
|
|
53
|
+
const type = r.headers.get("content-type") ?? "application/octet-stream";
|
|
54
|
+
return new Response(r.body, { headers: { "content-type": type, "cache-control": "no-store" } });
|
|
51
55
|
}
|
|
52
56
|
const r = await c.call("/releases");
|
|
53
57
|
if (!r.ok) return json({ error: "The revisions could not be read." }, 502);
|
package/src/version.ts
CHANGED