bearminion 1.16.1 → 1.16.2
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/CHANGELOG.md +6 -0
- package/dist/hosted-astro.js +1 -1
- package/dist/{hosted-middleware-qAgd_XC5.js → hosted-middleware-BQPW2YiB.js} +29 -3
- package/dist/hosted.js +1 -1
- package/package.json +1 -1
- package/registry/default/files/src/components/sections/logo-strip/LogoStrip.astro +3 -0
- package/registry/default/registry.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# bearminion
|
|
2
2
|
|
|
3
|
+
## 1.16.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a851229: Hosted editor: a page that uses an image uploaded after the last build no longer answers 500. The template's `Seo` (share image) and `LogoStrip` components threw for a file the build does not hold; on the hosted editor they now draw it from the editor's image route or leave it out. A page that cannot be drawn shows the signed-in person the reason, with the editor script on it, instead of a blank 500.
|
|
8
|
+
|
|
3
9
|
## 1.16.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/hosted-astro.js
CHANGED
|
@@ -60,7 +60,7 @@ function readCookies(header) {
|
|
|
60
60
|
}
|
|
61
61
|
return cookies;
|
|
62
62
|
}
|
|
63
|
-
function escapeHtml(text) {
|
|
63
|
+
function escapeHtml$1(text) {
|
|
64
64
|
return text.replace(/[&<>"']/g, (char) => `&#${char.charCodeAt(0)};`);
|
|
65
65
|
}
|
|
66
66
|
/** Only a path on this site: no other origin, no protocol-relative `//host`, no backslash tricks. */
|
|
@@ -69,7 +69,7 @@ function safeReturnTo(value) {
|
|
|
69
69
|
return value;
|
|
70
70
|
}
|
|
71
71
|
function page(status, title, message, extra) {
|
|
72
|
-
const body = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${escapeHtml(title)}</title><body style="font:16px system-ui;max-width:32rem;margin:4rem auto;padding:0 1rem"><h1 style="font-size:1.25rem">${escapeHtml(title)}</h1><p>${escapeHtml(message)}</p>`;
|
|
72
|
+
const body = `<!doctype html><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${escapeHtml$1(title)}</title><body style="font:16px system-ui;max-width:32rem;margin:4rem auto;padding:0 1rem"><h1 style="font-size:1.25rem">${escapeHtml$1(title)}</h1><p>${escapeHtml$1(message)}</p>`;
|
|
73
73
|
return new Response(body, {
|
|
74
74
|
status,
|
|
75
75
|
headers: {
|
|
@@ -333,6 +333,15 @@ function redirectToSignIn(request) {
|
|
|
333
333
|
}
|
|
334
334
|
});
|
|
335
335
|
}
|
|
336
|
+
const escapeHtml = (text) => text.replace(/[&<>"']/g, (char) => `&#${char.charCodeAt(0)};`);
|
|
337
|
+
/**
|
|
338
|
+
* What a signed-in person sees when their page could not be drawn: the reason, in words, instead of a blank 500. Only
|
|
339
|
+
* people with push access to the repository get here, so the message may name files and fields.
|
|
340
|
+
*/
|
|
341
|
+
function failedPage(error) {
|
|
342
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
343
|
+
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>This page could not be drawn</title><style>body{font:16px/1.5 system-ui,sans-serif;max-width:42rem;margin:12vh auto;padding:0 1.25rem;color:#1d1b18}pre{white-space:pre-wrap;background:#f4f1ec;padding:1rem;border-radius:.5rem;font-size:.875rem}</style></head><body><h1>This page could not be drawn</h1><p>The content in the repository does not render. Fix it in the editor, or in the repository, and reload.</p><pre>${escapeHtml(reason)}</pre></body></html>`;
|
|
344
|
+
}
|
|
336
345
|
function createHostedMiddleware(editor, options = {}) {
|
|
337
346
|
const required = options.signIn !== "optional";
|
|
338
347
|
return async ({ request, locals }, next) => {
|
|
@@ -351,7 +360,24 @@ function createHostedMiddleware(editor, options = {}) {
|
|
|
351
360
|
});
|
|
352
361
|
}
|
|
353
362
|
locals.bearminion = scope;
|
|
354
|
-
|
|
363
|
+
let response;
|
|
364
|
+
try {
|
|
365
|
+
response = await next();
|
|
366
|
+
} catch (error) {
|
|
367
|
+
if (!isPageLoad(request)) throw error;
|
|
368
|
+
const page = new Response(failedPage(error), {
|
|
369
|
+
status: 200,
|
|
370
|
+
headers: { "content-type": "text/html; charset=utf-8" }
|
|
371
|
+
});
|
|
372
|
+
const withOverlay = await editor.inject(request, page);
|
|
373
|
+
const headers = new Headers(withOverlay.headers);
|
|
374
|
+
headers.set("cache-control", "private, no-store");
|
|
375
|
+
return new Response(withOverlay.body, {
|
|
376
|
+
status: 500,
|
|
377
|
+
headers
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
return editor.inject(request, response);
|
|
355
381
|
};
|
|
356
382
|
}
|
|
357
383
|
//#endregion
|
package/dist/hosted.js
CHANGED
|
@@ -5,7 +5,7 @@ import { n as createMigrator } from "./migrate-b408EaLp.js";
|
|
|
5
5
|
import { i as resolveMaxImageBytes, r as resolveConvert } from "./upload-rules-Cao9uY5K.js";
|
|
6
6
|
import { f as DEFAULT_VIDEO_BYTE_LIMIT, n as missingImageSvg, r as handleEditorRequest, t as githubStore } from "./github-store-D3LEUhcM.js";
|
|
7
7
|
import { S as isAssetPath } from "./draft-store-DBEfw_Gq.js";
|
|
8
|
-
import { n as AUTH_PREFIX, r as createHostedAuth, t as createHostedMiddleware } from "./hosted-middleware-
|
|
8
|
+
import { n as AUTH_PREFIX, r as createHostedAuth, t as createHostedMiddleware } from "./hosted-middleware-BQPW2YiB.js";
|
|
9
9
|
//#region src/hosted-context.ts
|
|
10
10
|
/** The context for `handleEditorRequest`. */
|
|
11
11
|
function createHostedContext(options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bearminion",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.2",
|
|
4
4
|
"description": "A git-based CMS for Astro with no database and no server: JSON content in your repo, edited by clicking on the page during astro dev.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Jakub Lange",
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { Section } from '../definitions'
|
|
3
3
|
import Image from '../../atoms/Image.astro'
|
|
4
4
|
import { isRemote, resolveLocalAsset } from '../../../lib/assets'
|
|
5
|
+
import { editing } from '../../../lib/editing'
|
|
5
6
|
import SectionShell from '../../molecules/SectionShell.astro'
|
|
6
7
|
|
|
7
8
|
interface Props {
|
|
@@ -19,6 +20,8 @@ function showImage(src: string) {
|
|
|
19
20
|
if (src === 'placeholder') return false
|
|
20
21
|
if (isRemote(src)) return true
|
|
21
22
|
if (src.replace(/^\//, '').startsWith('src/assets/') && !resolveLocalAsset(src)) {
|
|
23
|
+
// Just uploaded in the hosted editor: <Image> draws it from the editor's route.
|
|
24
|
+
if (editing) return true
|
|
22
25
|
throw new Error(`No file in src/assets for image path "${src}". Restore the file, or choose another image in the editor and save.`)
|
|
23
26
|
}
|
|
24
27
|
return Boolean(resolveLocalAsset(src))
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"template": "default",
|
|
4
|
-
"version": "1.16.
|
|
4
|
+
"version": "1.16.2",
|
|
5
5
|
"files": {
|
|
6
6
|
"src/components/atoms/Button.astro": {
|
|
7
7
|
"hash": "7be42b3dc3a3b59bec169de32a9d801904689e2705473d1945724658dc799043",
|
|
@@ -144,8 +144,10 @@
|
|
|
144
144
|
"history": []
|
|
145
145
|
},
|
|
146
146
|
"src/components/sections/logo-strip/LogoStrip.astro": {
|
|
147
|
-
"hash": "
|
|
148
|
-
"history": [
|
|
147
|
+
"hash": "b647d634c1a382779dc22550c84af65a88afbec8119a5b51ee058c521b7b95b5",
|
|
148
|
+
"history": [
|
|
149
|
+
"0bb887f0282bf9d7d0ae65a3afc7f3813c58247c0aa70a4962a6a5e35b8e1c71"
|
|
150
|
+
]
|
|
149
151
|
},
|
|
150
152
|
"src/components/sections/logo-strip/definition.ts": {
|
|
151
153
|
"hash": "de761c20c0ce0b5f4fcc1ad96535addf6f7fb668abd1954709d2f68f72ccffdd",
|