@umami/shiso 0.9.0 → 0.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umami/shiso",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "A content layer for Next.js",
5
5
  "homepage": "https://umami.is/shiso",
6
6
  "repository": {
package/server/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export declare const parseMdx: (file: string) => Promise<any>;
2
+ export declare function getContentIds(folder: string): Promise<any>;
2
3
  export declare function getContent(params: {
3
4
  id: string[];
4
5
  }, folder: string): Promise<any>;
package/server/index.js CHANGED
@@ -41,6 +41,7 @@ import rehypeHighlight from 'rehype-highlight';
41
41
  import matter from 'gray-matter';
42
42
  import fs from 'node:fs/promises';
43
43
  import path from 'node:path';
44
+ import recursive from 'recursive-readdir';
44
45
  export var parseMdx = cache(function (file) { return __awaiter(void 0, void 0, void 0, function () {
45
46
  var postContent, _a, frontmatter, mdxContent, id, anchors, modifiedContent, code, _b;
46
47
  return __generator(this, function (_c) {
@@ -83,6 +84,23 @@ export var parseMdx = cache(function (file) { return __awaiter(void 0, void 0, v
83
84
  }
84
85
  });
85
86
  }); });
87
+ export function getContentIds(folder) {
88
+ return __awaiter(this, void 0, void 0, function () {
89
+ var dir, files;
90
+ return __generator(this, function (_a) {
91
+ switch (_a.label) {
92
+ case 0:
93
+ dir = path.resolve(folder);
94
+ return [4 /*yield*/, recursive(dir)];
95
+ case 1:
96
+ files = _a.sent();
97
+ return [2 /*return*/, files.map(function (file) {
98
+ return file.replace('.mdx', '').replace(dir, '').replace(/\\/g, '/').replace(/^\//, '');
99
+ })];
100
+ }
101
+ });
102
+ });
103
+ }
86
104
  export function getContent(params, folder) {
87
105
  return __awaiter(this, void 0, void 0, function () {
88
106
  var _a, id, name;