@tideworthy/tidysites-platform 0.10.10 → 0.10.12
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 +8 -0
- package/package.json +1 -1
- package/src/editor/TidyEditor.astro +1 -1
- package/src/editor/request.ts +3 -3
- package/src/middleware.ts +29 -5
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.12
|
|
4
|
+
|
|
5
|
+
- The staging site is never indexed: every response carries `X-Robots-Tag: noindex, nofollow`, robots.txt disallows everything and the sitemap answers 404. The publish crawl still gets the real robots.txt and sitemap for the live copy.
|
|
6
|
+
|
|
7
|
+
## 0.10.11
|
|
8
|
+
|
|
9
|
+
- Editor bar: Request a change comes first and carries the blue; Edit follows it plain.
|
|
10
|
+
|
|
3
11
|
## 0.10.10
|
|
4
12
|
|
|
5
13
|
- Editor: the bar reads Edit, Request a change, Revisions, Publish live; Publish live is green.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tideworthy/tidysites-platform",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.12",
|
|
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",
|
|
@@ -58,7 +58,7 @@ const htmlClass = !signedIn ? (signInUrl ? "tidy-has-bar tidy-idle" : "") : !act
|
|
|
58
58
|
<span class="tidy-bar-label"><span class="tidy-bar-dot" aria-hidden="true"></span>{label} website<span class="tidy-bar-note">A private copy to see working changes on the website, not publicly accessible.</span></span>
|
|
59
59
|
<div class="tidy-bar-actions" id="tidy-bar-actions">
|
|
60
60
|
{!signedIn && <a class="tidy-btn tidy-btn-primary" href={signInUrl!}>Sign in to edit</a>}
|
|
61
|
-
{signedIn && !active && <a class="tidy-btn
|
|
61
|
+
{signedIn && !active && <a class="tidy-btn" href={toggle(true)}>Edit</a>}
|
|
62
62
|
{signedIn && active && !editable && <a class="tidy-btn" href={toggle(false)}>Done</a>}
|
|
63
63
|
</div>
|
|
64
64
|
</div>
|
package/src/editor/request.ts
CHANGED
|
@@ -85,10 +85,10 @@ export function mountRequestChange(): void {
|
|
|
85
85
|
body.focus();
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const barBtn = el("button", { type: "button", class: "tidy-btn", text: "Request a change" });
|
|
88
|
+
const barBtn = el("button", { type: "button", class: "tidy-btn tidy-btn-primary", text: "Request a change" });
|
|
89
89
|
barBtn.addEventListener("click", render);
|
|
90
|
-
//
|
|
91
|
-
actions.
|
|
90
|
+
// First on the bar: most people are here to ask for a change, not to edit.
|
|
91
|
+
actions.prepend(barBtn);
|
|
92
92
|
|
|
93
93
|
const fab = el("button", { type: "button", class: "tidy-fab", title: "Request a change", "aria-label": "Request a change" });
|
|
94
94
|
fab.innerHTML = '<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 20h9"/><path d="M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z"/></svg>';
|
package/src/middleware.ts
CHANGED
|
@@ -1,20 +1,44 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Astro middleware registered by tidyPlatform(): the framing policy from
|
|
3
|
+
* TIDY_FRAME_ANCESTORS, and no indexing of the staging site. This worker is
|
|
4
|
+
* the staging site (the live site is a static copy served by its own small
|
|
5
|
+
* worker), so every answer here carries noindex, robots.txt disallows
|
|
6
|
+
* everything and the sitemap is gone. The publish crawl identifies itself
|
|
7
|
+
* and gets the real robots.txt and sitemap, which is what the live copy
|
|
8
|
+
* ships.
|
|
9
|
+
*/
|
|
2
10
|
import type { MiddlewareHandler } from "astro";
|
|
3
11
|
import { workerEnv } from "./lib/env";
|
|
4
12
|
import { applyFramePolicy, frameAncestors } from "./lib/frame";
|
|
5
13
|
|
|
6
|
-
|
|
14
|
+
const PUBLISH_CRAWL = "tidysites-publish";
|
|
15
|
+
const NOINDEX = "noindex, nofollow";
|
|
16
|
+
|
|
17
|
+
export const onRequest: MiddlewareHandler = async (context, next) => {
|
|
18
|
+
const crawl = context.request.headers.get("user-agent") === PUBLISH_CRAWL;
|
|
19
|
+
if (!crawl) {
|
|
20
|
+
const path = context.url.pathname;
|
|
21
|
+
if (path === "/robots.txt") {
|
|
22
|
+
return new Response("User-agent: *\nDisallow: /\n", { headers: { "content-type": "text/plain; charset=utf-8", "cache-control": "no-store", "x-robots-tag": NOINDEX } });
|
|
23
|
+
}
|
|
24
|
+
if (path === "/sitemap.xml" || path === "/sitemap-index.xml" || /^\/sitemap-\d+\.xml$/.test(path)) {
|
|
25
|
+
return new Response("Not found", { status: 404, headers: { "cache-control": "no-store", "x-robots-tag": NOINDEX } });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
7
28
|
const response = await next();
|
|
8
29
|
const env = await workerEnv();
|
|
9
30
|
const ancestors = frameAncestors(env?.TIDY_FRAME_ANCESTORS);
|
|
10
|
-
|
|
31
|
+
const apply = (headers: Headers) => {
|
|
32
|
+
if (ancestors.length > 0) applyFramePolicy(headers, ancestors);
|
|
33
|
+
if (!crawl) headers.set("x-robots-tag", NOINDEX);
|
|
34
|
+
};
|
|
11
35
|
// Response headers can be immutable (static assets, redirects); rebuild when so.
|
|
12
36
|
try {
|
|
13
|
-
|
|
37
|
+
apply(response.headers);
|
|
14
38
|
return response;
|
|
15
39
|
} catch {
|
|
16
40
|
const copy = new Response(response.body, response);
|
|
17
|
-
|
|
41
|
+
apply(copy.headers);
|
|
18
42
|
return copy;
|
|
19
43
|
}
|
|
20
44
|
};
|
package/src/version.ts
CHANGED