@augmenting-integrations/content 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Augmenting Integrations LLC
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.
@@ -0,0 +1,21 @@
1
+ import "server-only";
2
+ export type ContentDoc = {
3
+ slug: string;
4
+ frontmatter: Record<string, unknown>;
5
+ body: string;
6
+ };
7
+ export type ContentLoader = {
8
+ getContent(slug: string): Promise<ContentDoc | null>;
9
+ listContent(): Promise<Array<Pick<ContentDoc, "slug" | "frontmatter">>>;
10
+ };
11
+ /**
12
+ * Build a content loader rooted at a directory relative to the consuming
13
+ * app's cwd (typically `content`). Apps call this once at module scope.
14
+ *
15
+ * To swap to a CMS (e.g. Payload), replace this implementation while keeping
16
+ * the `ContentLoader` shape stable.
17
+ */
18
+ export declare function createContentLoader(opts?: {
19
+ dir?: string;
20
+ }): ContentLoader;
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AAKrB,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACrD,WAAW,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;CACzE,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,aAAa,CAkC9E"}
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ import "server-only";
2
+ import { promises as fs } from "node:fs";
3
+ import path from "node:path";
4
+ import matter from "gray-matter";
5
+ /**
6
+ * Build a content loader rooted at a directory relative to the consuming
7
+ * app's cwd (typically `content`). Apps call this once at module scope.
8
+ *
9
+ * To swap to a CMS (e.g. Payload), replace this implementation while keeping
10
+ * the `ContentLoader` shape stable.
11
+ */
12
+ export function createContentLoader(opts = {}) {
13
+ const dir = opts.dir ?? "content";
14
+ const contentDir = path.resolve(process.cwd(), dir);
15
+ return {
16
+ async getContent(slug) {
17
+ const file = path.join(contentDir, `${slug}.mdx`);
18
+ try {
19
+ const raw = await fs.readFile(file, "utf-8");
20
+ const { data, content } = matter(raw);
21
+ return { slug, frontmatter: data, body: content };
22
+ }
23
+ catch {
24
+ return null;
25
+ }
26
+ },
27
+ async listContent() {
28
+ try {
29
+ const files = await fs.readdir(contentDir);
30
+ const docs = await Promise.all(files
31
+ .filter((f) => f.endsWith(".mdx"))
32
+ .map(async (f) => {
33
+ const slug = f.replace(/\.mdx$/, "");
34
+ const raw = await fs.readFile(path.join(contentDir, f), "utf-8");
35
+ const { data } = matter(raw);
36
+ return { slug, frontmatter: data };
37
+ }));
38
+ return docs;
39
+ }
40
+ catch {
41
+ return [];
42
+ }
43
+ },
44
+ };
45
+ }
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,aAAa,CAAC;AAajC;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAyB,EAAE;IAC7D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,SAAS,CAAC;IAClC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;IAEpD,OAAO;QACL,KAAK,CAAC,UAAU,CAAC,IAAI;YACnB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,MAAM,CAAC,CAAC;YAClD,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBAC7C,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;gBACtC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;YACpD,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,KAAK,CAAC,WAAW;YACf,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBAC3C,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,CAC5B,KAAK;qBACF,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;qBACjC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;oBACf,MAAM,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;oBACrC,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;oBACjE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;oBAC7B,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;gBACrC,CAAC,CAAC,CACL,CAAC;gBACF,OAAO,IAAI,CAAC;YACd,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
package/dist/index.mjs ADDED
@@ -0,0 +1,41 @@
1
+ // src/index.ts
2
+ import "server-only";
3
+ import { promises as fs } from "fs";
4
+ import path from "path";
5
+ import matter from "gray-matter";
6
+ function createContentLoader(opts = {}) {
7
+ const dir = opts.dir ?? "content";
8
+ const contentDir = path.resolve(process.cwd(), dir);
9
+ return {
10
+ async getContent(slug) {
11
+ const file = path.join(contentDir, `${slug}.mdx`);
12
+ try {
13
+ const raw = await fs.readFile(file, "utf-8");
14
+ const { data, content } = matter(raw);
15
+ return { slug, frontmatter: data, body: content };
16
+ } catch {
17
+ return null;
18
+ }
19
+ },
20
+ async listContent() {
21
+ try {
22
+ const files = await fs.readdir(contentDir);
23
+ const docs = await Promise.all(
24
+ files.filter((f) => f.endsWith(".mdx")).map(async (f) => {
25
+ const slug = f.replace(/\.mdx$/, "");
26
+ const raw = await fs.readFile(path.join(contentDir, f), "utf-8");
27
+ const { data } = matter(raw);
28
+ return { slug, frontmatter: data };
29
+ })
30
+ );
31
+ return docs;
32
+ } catch {
33
+ return [];
34
+ }
35
+ }
36
+ };
37
+ }
38
+ export {
39
+ createContentLoader
40
+ };
41
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import \"server-only\";\nimport { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport matter from \"gray-matter\";\n\nexport type ContentDoc = {\n slug: string;\n frontmatter: Record<string, unknown>;\n body: string;\n};\n\nexport type ContentLoader = {\n getContent(slug: string): Promise<ContentDoc | null>;\n listContent(): Promise<Array<Pick<ContentDoc, \"slug\" | \"frontmatter\">>>;\n};\n\n/**\n * Build a content loader rooted at a directory relative to the consuming\n * app's cwd (typically `content`). Apps call this once at module scope.\n *\n * To swap to a CMS (e.g. Payload), replace this implementation while keeping\n * the `ContentLoader` shape stable.\n */\nexport function createContentLoader(opts: { dir?: string } = {}): ContentLoader {\n const dir = opts.dir ?? \"content\";\n const contentDir = path.resolve(process.cwd(), dir);\n\n return {\n async getContent(slug) {\n const file = path.join(contentDir, `${slug}.mdx`);\n try {\n const raw = await fs.readFile(file, \"utf-8\");\n const { data, content } = matter(raw);\n return { slug, frontmatter: data, body: content };\n } catch {\n return null;\n }\n },\n async listContent() {\n try {\n const files = await fs.readdir(contentDir);\n const docs = await Promise.all(\n files\n .filter((f) => f.endsWith(\".mdx\"))\n .map(async (f) => {\n const slug = f.replace(/\\.mdx$/, \"\");\n const raw = await fs.readFile(path.join(contentDir, f), \"utf-8\");\n const { data } = matter(raw);\n return { slug, frontmatter: data };\n }),\n );\n return docs;\n } catch {\n return [];\n }\n },\n };\n}\n"],"mappings":";AAAA,OAAO;AACP,SAAS,YAAY,UAAU;AAC/B,OAAO,UAAU;AACjB,OAAO,YAAY;AAoBZ,SAAS,oBAAoB,OAAyB,CAAC,GAAkB;AAC9E,QAAM,MAAM,KAAK,OAAO;AACxB,QAAM,aAAa,KAAK,QAAQ,QAAQ,IAAI,GAAG,GAAG;AAElD,SAAO;AAAA,IACL,MAAM,WAAW,MAAM;AACrB,YAAM,OAAO,KAAK,KAAK,YAAY,GAAG,IAAI,MAAM;AAChD,UAAI;AACF,cAAM,MAAM,MAAM,GAAG,SAAS,MAAM,OAAO;AAC3C,cAAM,EAAE,MAAM,QAAQ,IAAI,OAAO,GAAG;AACpC,eAAO,EAAE,MAAM,aAAa,MAAM,MAAM,QAAQ;AAAA,MAClD,QAAQ;AACN,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA,MAAM,cAAc;AAClB,UAAI;AACF,cAAM,QAAQ,MAAM,GAAG,QAAQ,UAAU;AACzC,cAAM,OAAO,MAAM,QAAQ;AAAA,UACzB,MACG,OAAO,CAAC,MAAM,EAAE,SAAS,MAAM,CAAC,EAChC,IAAI,OAAO,MAAM;AAChB,kBAAM,OAAO,EAAE,QAAQ,UAAU,EAAE;AACnC,kBAAM,MAAM,MAAM,GAAG,SAAS,KAAK,KAAK,YAAY,CAAC,GAAG,OAAO;AAC/D,kBAAM,EAAE,KAAK,IAAI,OAAO,GAAG;AAC3B,mBAAO,EAAE,MAAM,aAAa,KAAK;AAAA,UACnC,CAAC;AAAA,QACL;AACA,eAAO;AAAA,MACT,QAAQ;AACN,eAAO,CAAC;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@augmenting-integrations/content",
3
+ "version": "0.1.0",
4
+ "description": "MDX content loader (server-only). Reads /content/*.mdx files relative to the consuming app's cwd.",
5
+ "license": "MIT",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "sideEffects": [
10
+ "./src/index.ts",
11
+ "./dist/index.js",
12
+ "./dist/index.cjs"
13
+ ],
14
+ "main": "./dist/index.cjs",
15
+ "module": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js",
21
+ "require": "./dist/index.cjs"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "README.md"
27
+ ],
28
+ "dependencies": {
29
+ "gray-matter": "^4.0.3"
30
+ },
31
+ "peerDependencies": {
32
+ "server-only": "^0.0.1"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^20.17.6",
36
+ "server-only": "^0.0.1",
37
+ "tsup": "^8.3.5",
38
+ "typescript": "^5.7.2",
39
+ "vitest": "^4.1.5"
40
+ },
41
+ "scripts": {
42
+ "build": "tsup",
43
+ "clean": "rm -rf dist",
44
+ "test": "vitest run --passWithNoTests"
45
+ }
46
+ }