@umami/shiso 0.38.0 → 0.39.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 +1 -1
- package/server/index.d.ts +1 -0
- package/server/index.js +20 -11
package/package.json
CHANGED
package/server/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ declare module '@umami/shiso/server' {
|
|
|
24
24
|
slug: string[];
|
|
25
25
|
}>;
|
|
26
26
|
}) => Promise<ReactElement<unknown, string | import("react").JSXElementConstructor<any>>>;
|
|
27
|
+
renderCollection: (render: (props: ShisoRenderProps) => ReactElement) => () => Promise<ReactElement<unknown, string | import("react").JSXElementConstructor<any>>>;
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
|
package/server/index.js
CHANGED
|
@@ -148,7 +148,7 @@ export function next(type, config) {
|
|
|
148
148
|
function renderPage(render) {
|
|
149
149
|
var _this = this;
|
|
150
150
|
return function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
151
|
-
var slug, file,
|
|
151
|
+
var slug, file, content;
|
|
152
152
|
var _c, _d;
|
|
153
153
|
var params = _b.params;
|
|
154
154
|
return __generator(this, function (_e) {
|
|
@@ -157,21 +157,30 @@ export function next(type, config) {
|
|
|
157
157
|
case 1:
|
|
158
158
|
slug = ((_d = (_c = (_e.sent())) === null || _c === void 0 ? void 0 : _c.slug) === null || _d === void 0 ? void 0 : _d.join('/')) || 'index';
|
|
159
159
|
file = path.join(dir, "".concat(slug, ".mdx"));
|
|
160
|
-
return [4 /*yield*/, recursive(dir)];
|
|
161
|
-
case 2:
|
|
162
|
-
files = _e.sent();
|
|
163
160
|
return [4 /*yield*/, getContent(file)];
|
|
164
|
-
case
|
|
161
|
+
case 2:
|
|
165
162
|
content = _e.sent();
|
|
166
|
-
|
|
163
|
+
return [2 /*return*/, render({ type: type, config: config, content: content })];
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}); };
|
|
167
|
+
}
|
|
168
|
+
function renderCollection(render) {
|
|
169
|
+
var _this = this;
|
|
170
|
+
return function () { return __awaiter(_this, void 0, void 0, function () {
|
|
171
|
+
var files, content;
|
|
172
|
+
return __generator(this, function (_a) {
|
|
173
|
+
switch (_a.label) {
|
|
174
|
+
case 0: return [4 /*yield*/, recursive(dir)];
|
|
175
|
+
case 1:
|
|
176
|
+
files = _a.sent();
|
|
167
177
|
return [4 /*yield*/, Promise.all(files.map(function (file) { return getContent(file); }))];
|
|
168
|
-
case
|
|
169
|
-
content =
|
|
170
|
-
|
|
171
|
-
case 5: return [2 /*return*/, render({ type: type, config: config, content: content })];
|
|
178
|
+
case 2:
|
|
179
|
+
content = _a.sent();
|
|
180
|
+
return [2 /*return*/, render({ type: type, config: config, content: content })];
|
|
172
181
|
}
|
|
173
182
|
});
|
|
174
183
|
}); };
|
|
175
184
|
}
|
|
176
|
-
return { generateMetadata: generateMetadata, generateStaticParams: generateStaticParams, renderPage: renderPage };
|
|
185
|
+
return { generateMetadata: generateMetadata, generateStaticParams: generateStaticParams, renderPage: renderPage, renderCollection: renderCollection };
|
|
177
186
|
}
|