@contentrail/astro 0.2.0 → 0.2.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/README.md CHANGED
@@ -22,10 +22,10 @@ pnpm install
22
22
  pnpm --filter @contentrail/astro build
23
23
  ```
24
24
 
25
- ### From npm (upcoming `0.2.0` after authorized publish)
25
+ ### From npm (`0.2.2`)
26
26
 
27
27
  ```sh
28
- pnpm add @contentrail/core@0.2.0 @contentrail/reader@0.2.0 @contentrail/astro@0.2.0 zod@^4.6.7
28
+ pnpm add @contentrail/core@0.2.2 @contentrail/reader@0.2.2 @contentrail/astro@0.2.2 zod@^4.6.7
29
29
  pnpm add -D astro@^7.3.3
30
30
  ```
31
31
 
@@ -49,3 +49,13 @@ const entries = await rail.loadCollection(articles);
49
49
  ```
50
50
 
51
51
  This package re-exports the Node reader. Do not import it from client-side scripts.
52
+
53
+ ## Self-hosted `/admin`
54
+
55
+ Optional. Install `@contentrail/editor` and `preact`, then add:
56
+
57
+ ```ts
58
+ import { contentrailAdmin } from "@contentrail/astro/admin";
59
+ ```
60
+
61
+ Existing public routes are unchanged. See `docs/ADMIN.md`. Next.js and other frameworks are **not** claimed.
@@ -0,0 +1,37 @@
1
+ ---
2
+ export const prerender = true;
3
+ ---
4
+
5
+ <html lang="en">
6
+ <head>
7
+ <meta charset="utf-8" />
8
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
9
+ <meta name="robots" content="noindex" />
10
+ <title>ContentRail Admin</title>
11
+ </head>
12
+ <body>
13
+ <div id="contentrail-admin"></div>
14
+ <script>
15
+ import { mountAdmin } from "@contentrail/editor";
16
+ import "@contentrail/editor/styles.css";
17
+ import {
18
+ site,
19
+ apiBaseUrl,
20
+ title,
21
+ pageSize,
22
+ } from "virtual:contentrail-admin-config";
23
+
24
+ const root = document.getElementById("contentrail-admin");
25
+ if (!(root instanceof HTMLElement)) {
26
+ throw new Error("#contentrail-admin is required");
27
+ }
28
+ mountAdmin({
29
+ target: root,
30
+ sites: [site],
31
+ apiBaseUrl,
32
+ title,
33
+ pageSize,
34
+ });
35
+ </script>
36
+ </body>
37
+ </html>
@@ -0,0 +1,9 @@
1
+ import type { AstroIntegration } from "astro";
2
+ import { type ContentrailAdminOptions } from "@contentrail/editor/vite";
3
+ export type { ContentrailAdminOptions };
4
+ /**
5
+ * Injects `/admin` into an Astro site without replacing existing public routes.
6
+ * Requires `@contentrail/editor` and `preact` in the website project.
7
+ */
8
+ export declare function contentrailAdmin(options: ContentrailAdminOptions): AstroIntegration;
9
+ //# sourceMappingURL=admin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,0BAA0B,CAAC;AAElC,YAAY,EAAE,uBAAuB,EAAE,CAAC;AAExC;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,uBAAuB,GAC/B,gBAAgB,CAkBlB"}
package/dist/admin.js ADDED
@@ -0,0 +1,26 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { contentrailAdmin as viteContentrailAdmin, } from "@contentrail/editor/vite";
3
+ /**
4
+ * Injects `/admin` into an Astro site without replacing existing public routes.
5
+ * Requires `@contentrail/editor` and `preact` in the website project.
6
+ */
7
+ export function contentrailAdmin(options) {
8
+ const page = fileURLToPath(new URL("../admin-page.astro", import.meta.url));
9
+ return {
10
+ name: "contentrail-admin",
11
+ hooks: {
12
+ "astro:config:setup": ({ injectRoute, updateConfig }) => {
13
+ updateConfig({
14
+ vite: {
15
+ plugins: [viteContentrailAdmin({ ...options, serveRoute: false })],
16
+ },
17
+ });
18
+ injectRoute({
19
+ pattern: "/admin",
20
+ entrypoint: page,
21
+ });
22
+ },
23
+ },
24
+ };
25
+ }
26
+ //# sourceMappingURL=admin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.js","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EACL,gBAAgB,IAAI,oBAAoB,GAEzC,MAAM,0BAA0B,CAAC;AAIlC;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAgC;IAEhC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,qBAAqB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5E,OAAO;QACL,IAAI,EAAE,mBAAmB;QACzB,KAAK,EAAE;YACL,oBAAoB,EAAE,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,EAAE;gBACtD,YAAY,CAAC;oBACX,IAAI,EAAE;wBACJ,OAAO,EAAE,CAAC,oBAAoB,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;qBACnE;iBACF,CAAC,CAAC;gBACH,WAAW,CAAC;oBACV,OAAO,EAAE,QAAQ;oBACjB,UAAU,EAAE,IAAI;iBACjB,CAAC,CAAC;YACL,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentrail/astro",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Astro build-time helpers for ContentRail local JSON content.",
@@ -15,29 +15,45 @@
15
15
  "import": "./dist/index.js",
16
16
  "node": "./dist/index.js"
17
17
  },
18
+ "./admin": {
19
+ "types": "./dist/admin.d.ts",
20
+ "import": "./dist/admin.js",
21
+ "node": "./dist/admin.js"
22
+ },
18
23
  "./package.json": "./package.json"
19
24
  },
20
25
  "files": [
21
26
  "dist",
27
+ "admin-page.astro",
22
28
  "README.md",
23
29
  "LICENSE"
24
30
  ],
25
31
  "dependencies": {
26
- "@contentrail/core": "0.2.0",
27
- "@contentrail/reader": "0.2.0"
32
+ "@contentrail/core": "0.2.2",
33
+ "@contentrail/reader": "0.2.2"
28
34
  },
29
35
  "peerDependencies": {
30
- "astro": "^7.3.3"
36
+ "astro": "^7.3.3",
37
+ "preact": "^10.26.0",
38
+ "@contentrail/editor": "^0.2.2"
31
39
  },
32
40
  "peerDependenciesMeta": {
41
+ "@contentrail/editor": {
42
+ "optional": true
43
+ },
33
44
  "astro": {
34
45
  "optional": true
46
+ },
47
+ "preact": {
48
+ "optional": true
35
49
  }
36
50
  },
37
51
  "devDependencies": {
38
52
  "@types/node": "^22.20.5",
39
53
  "astro": "7.3.8",
40
- "typescript": "5.9.3"
54
+ "preact": "^10.26.9",
55
+ "typescript": "5.9.3",
56
+ "@contentrail/editor": "0.2.2"
41
57
  },
42
58
  "repository": {
43
59
  "type": "git",