@augmenting-integrations/content 0.1.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/dist/index.cjs ADDED
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ createContentLoader: () => createContentLoader
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+ var import_server_only = require("server-only");
37
+ var import_node_fs = require("fs");
38
+ var import_node_path = __toESM(require("path"));
39
+ var import_gray_matter = __toESM(require("gray-matter"));
40
+ function createContentLoader(opts = {}) {
41
+ const dir = opts.dir ?? "content";
42
+ const contentDir = import_node_path.default.resolve(process.cwd(), dir);
43
+ return {
44
+ async getContent(slug) {
45
+ const file = import_node_path.default.join(contentDir, `${slug}.mdx`);
46
+ try {
47
+ const raw = await import_node_fs.promises.readFile(file, "utf-8");
48
+ const { data, content } = (0, import_gray_matter.default)(raw);
49
+ return { slug, frontmatter: data, body: content };
50
+ } catch {
51
+ return null;
52
+ }
53
+ },
54
+ async listContent() {
55
+ try {
56
+ const files = await import_node_fs.promises.readdir(contentDir);
57
+ const docs = await Promise.all(
58
+ files.filter((f) => f.endsWith(".mdx")).map(async (f) => {
59
+ const slug = f.replace(/\.mdx$/, "");
60
+ const raw = await import_node_fs.promises.readFile(import_node_path.default.join(contentDir, f), "utf-8");
61
+ const { data } = (0, import_gray_matter.default)(raw);
62
+ return { slug, frontmatter: data };
63
+ })
64
+ );
65
+ return docs;
66
+ } catch {
67
+ return [];
68
+ }
69
+ }
70
+ };
71
+ }
72
+ // Annotate the CommonJS export names for ESM import in node:
73
+ 0 && (module.exports = {
74
+ createContentLoader
75
+ });
76
+ //# sourceMappingURL=index.cjs.map
@@ -1 +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":[]}
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;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAO;AACP,qBAA+B;AAC/B,uBAAiB;AACjB,yBAAmB;AAoBZ,SAAS,oBAAoB,OAAyB,CAAC,GAAkB;AAC9E,QAAM,MAAM,KAAK,OAAO;AACxB,QAAM,aAAa,iBAAAA,QAAK,QAAQ,QAAQ,IAAI,GAAG,GAAG;AAElD,SAAO;AAAA,IACL,MAAM,WAAW,MAAM;AACrB,YAAM,OAAO,iBAAAA,QAAK,KAAK,YAAY,GAAG,IAAI,MAAM;AAChD,UAAI;AACF,cAAM,MAAM,MAAM,eAAAC,SAAG,SAAS,MAAM,OAAO;AAC3C,cAAM,EAAE,MAAM,QAAQ,QAAI,mBAAAC,SAAO,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,eAAAD,SAAG,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,eAAAA,SAAG,SAAS,iBAAAD,QAAK,KAAK,YAAY,CAAC,GAAG,OAAO;AAC/D,kBAAM,EAAE,KAAK,QAAI,mBAAAE,SAAO,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":["path","fs","matter"]}
package/dist/index.js CHANGED
@@ -1,46 +1,41 @@
1
+ // src/index.ts
1
2
  import "server-only";
2
- import { promises as fs } from "node:fs";
3
- import path from "node:path";
3
+ import { promises as fs } from "fs";
4
+ import path from "path";
4
5
  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
- };
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
+ };
45
37
  }
38
+ export {
39
+ createContentLoader
40
+ };
46
41
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot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AG,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"}
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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@augmenting-integrations/content",
3
- "version": "0.1.0",
3
+ "version": "0.2.2",
4
4
  "description": "MDX content loader (server-only). Reads /content/*.mdx files relative to the consuming app's cwd.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
package/dist/index.mjs DELETED
@@ -1,41 +0,0 @@
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