@contentrail/astro 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +53 -2
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ContentRail contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@contentrail/astro`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Build-time helpers for loading ContentRail local JSON content in Astro.
|
|
4
|
+
|
|
5
|
+
**Supported / tested:** Astro **7.3.8** (peer `astro@^7.3.3`) on Node.js **≥ 22.12.0**.
|
|
6
|
+
|
|
7
|
+
Astro 5.x is **not** a supported peer. Official advisories including critical
|
|
8
|
+
[GHSA-26w7-cxv4-gfx2](https://github.com/advisories/GHSA-26w7-cxv4-gfx2)
|
|
9
|
+
(AVIF / Sharp RCE) list affected range `< 7.2.8`. ContentRail does not claim
|
|
10
|
+
Astro 5 is secure. See ADR 024 and `docs/RELEASE_READINESS_8A.md` § Phase 8A.2.
|
|
11
|
+
|
|
12
|
+
Consumers who enable Astro’s default Sharp image service must keep Astro (and
|
|
13
|
+
its Sharp optional dependency) on patched releases. ContentRail’s helper only
|
|
14
|
+
reads local JSON; it does not disable Sharp.
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
> **Not on the public npm registry yet.** Packages remain `"private": true`.
|
|
19
|
+
> See `docs/PUBLISHING.md`.
|
|
20
|
+
|
|
21
|
+
### Monorepo (current)
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
pnpm install
|
|
25
|
+
pnpm --filter @contentrail/astro build
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Intended after first public `0.1.0` release
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
pnpm add @contentrail/core @contentrail/reader @contentrail/astro zod
|
|
32
|
+
pnpm add -D astro@^7.3.3
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Workflow
|
|
36
|
+
|
|
37
|
+
1. Define a collection with `@contentrail/core`.
|
|
38
|
+
2. Add JSON files under `{rootDir}/{collection}/`.
|
|
39
|
+
3. Call `createContentRail` from Astro frontmatter or `getStaticPaths`.
|
|
40
|
+
4. Build with `astro build`. Invalid content fails the build.
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import path from "node:path";
|
|
44
|
+
import { createContentRail } from "@contentrail/astro";
|
|
45
|
+
import { articles } from "../content/config";
|
|
46
|
+
|
|
47
|
+
// Prefer process.cwd() for content roots. Astro 7 prerender bundles modules
|
|
48
|
+
// under dist/.prerender/, so import.meta.url-relative paths often break.
|
|
49
|
+
const rootDir = path.join(process.cwd(), "content");
|
|
50
|
+
const rail = await createContentRail({ rootDir });
|
|
51
|
+
const entries = await rail.loadCollection(articles);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This package re-exports the Node reader. Do not import it from client-side scripts.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ContentCollection } from "@contentrail/core";
|
|
2
|
+
import { ContentReadError, createLocalJsonSource, loadCollection, loadEntry, type LoadCollectionOptions, type LocalJsonSource } from "@contentrail/reader";
|
|
3
|
+
export interface ContentRailOptions {
|
|
4
|
+
/** Absolute or process-relative path to the content root directory. */
|
|
5
|
+
readonly rootDir: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ContentRail {
|
|
8
|
+
readonly source: LocalJsonSource;
|
|
9
|
+
loadEntry: <TCollection extends ContentCollection>(collection: TCollection, id: string) => ReturnType<typeof loadEntry<TCollection>>;
|
|
10
|
+
loadCollection: <TCollection extends ContentCollection>(collection: TCollection, options?: LoadCollectionOptions) => ReturnType<typeof loadCollection<TCollection>>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates a build-time ContentRail helper for Astro pages and `getStaticPaths`.
|
|
14
|
+
* Uses the local JSON reader. Not for browser bundles.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createContentRail(options: ContentRailOptions): Promise<ContentRail>;
|
|
17
|
+
export { ContentReadError, createLocalJsonSource, loadCollection, loadEntry };
|
|
18
|
+
export type { LoadCollectionOptions, LocalJsonSource };
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,SAAS,EACT,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,SAAS,EAAE,CAAC,WAAW,SAAS,iBAAiB,EAC/C,UAAU,EAAE,WAAW,EACvB,EAAE,EAAE,MAAM,KACP,UAAU,CAAC,OAAO,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/C,cAAc,EAAE,CAAC,WAAW,SAAS,iBAAiB,EACpD,UAAU,EAAE,WAAW,EACvB,OAAO,CAAC,EAAE,qBAAqB,KAC5B,UAAU,CAAC,OAAO,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC;CACrD;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,WAAW,CAAC,CAQtB;AAED,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC;AAE9E,YAAY,EAAE,qBAAqB,EAAE,eAAe,EAAE,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ContentReadError, createLocalJsonSource, loadCollection, loadEntry, } from "@contentrail/reader";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a build-time ContentRail helper for Astro pages and `getStaticPaths`.
|
|
4
|
+
* Uses the local JSON reader. Not for browser bundles.
|
|
5
|
+
*/
|
|
6
|
+
export async function createContentRail(options) {
|
|
7
|
+
const source = await createLocalJsonSource({ rootDir: options.rootDir });
|
|
8
|
+
return {
|
|
9
|
+
source,
|
|
10
|
+
loadEntry: (collection, id) => loadEntry(source, collection, id),
|
|
11
|
+
loadCollection: (collection, loadOptions) => loadCollection(source, collection, loadOptions),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export { ContentReadError, createLocalJsonSource, loadCollection, loadEntry };
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,SAAS,GAGV,MAAM,qBAAqB,CAAC;AAmB7B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAA2B;IAE3B,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACzE,OAAO;QACL,MAAM;QACN,SAAS,EAAE,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC;QAChE,cAAc,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,EAAE,CAC1C,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC;KAClD,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentrail/astro",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Astro build-time helpers for ContentRail local JSON content.",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22.12.0"
|
|
10
|
+
},
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"node": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@contentrail/core": "0.1.0",
|
|
27
|
+
"@contentrail/reader": "0.1.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"astro": "^7.3.3"
|
|
31
|
+
},
|
|
32
|
+
"peerDependenciesMeta": {
|
|
33
|
+
"astro": {
|
|
34
|
+
"optional": true
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^22.20.5",
|
|
39
|
+
"astro": "7.3.8",
|
|
40
|
+
"typescript": "5.9.3"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/Hridhin-k/contentrail.git",
|
|
45
|
+
"directory": "packages/astro"
|
|
46
|
+
},
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/Hridhin-k/contentrail/issues"
|
|
49
|
+
},
|
|
50
|
+
"homepage": "https://github.com/Hridhin-k/contentrail#readme",
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsc -p tsconfig.json",
|
|
56
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
57
|
+
"test": "pnpm run build && tsc -p tsconfig.test.json && node --test test-dist/**/*.test.js"
|
|
58
|
+
}
|
|
6
59
|
}
|