@umami/shiso 0.30.0 → 0.32.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/dist/index.css +94 -93
- package/dist/index.d.ts +14 -6
- package/dist/index.js +231 -207
- package/dist/index.mjs +236 -213
- package/package.json +3 -2
- package/server/index.d.ts +3 -19
- package/server/index.js +35 -13
package/server/index.js
CHANGED
|
@@ -39,10 +39,10 @@ import { compile } from '@mdx-js/mdx';
|
|
|
39
39
|
import remarkGfm from 'remark-gfm';
|
|
40
40
|
import rehypeHighlight from 'rehype-highlight';
|
|
41
41
|
import matter from 'gray-matter';
|
|
42
|
+
import recursive from 'recursive-readdir';
|
|
42
43
|
import fs from 'node:fs/promises';
|
|
43
44
|
import path from 'node:path';
|
|
44
|
-
|
|
45
|
-
export var getContent = cache(function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
+
export var parseFile = cache(function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
46
|
var postContent, _a, frontmatter, mdxContent, anchors_1, modifiedContent, code, _b, _c;
|
|
47
47
|
return __generator(this, function (_d) {
|
|
48
48
|
switch (_d.label) {
|
|
@@ -90,8 +90,23 @@ export var getContent = cache(function (file) { return __awaiter(void 0, void 0,
|
|
|
90
90
|
});
|
|
91
91
|
}); });
|
|
92
92
|
export function next(type, config) {
|
|
93
|
+
var _this = this;
|
|
93
94
|
var dir = path.join(config.contentDir, type);
|
|
94
95
|
var _a = config[type].title, title = _a === void 0 ? 'Shiso' : _a;
|
|
96
|
+
var getContent = function (file) { return __awaiter(_this, void 0, void 0, function () {
|
|
97
|
+
var content;
|
|
98
|
+
return __generator(this, function (_a) {
|
|
99
|
+
switch (_a.label) {
|
|
100
|
+
case 0: return [4 /*yield*/, parseFile(file)];
|
|
101
|
+
case 1:
|
|
102
|
+
content = _a.sent();
|
|
103
|
+
if (content) {
|
|
104
|
+
content['slug'] = getSlug(file, dir);
|
|
105
|
+
}
|
|
106
|
+
return [2 /*return*/, content];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}); };
|
|
95
110
|
function generateMetadata(_a) {
|
|
96
111
|
return __awaiter(this, arguments, void 0, function (_b) {
|
|
97
112
|
var name, file, content;
|
|
@@ -116,6 +131,9 @@ export function next(type, config) {
|
|
|
116
131
|
});
|
|
117
132
|
});
|
|
118
133
|
}
|
|
134
|
+
function getSlug(file, dir) {
|
|
135
|
+
return file.replace('.mdx', '').replace(dir, '').replace(/\\/g, '/').replace(/^\//, '');
|
|
136
|
+
}
|
|
119
137
|
function generateStaticParams() {
|
|
120
138
|
return __awaiter(this, void 0, void 0, function () {
|
|
121
139
|
var files;
|
|
@@ -124,12 +142,8 @@ export function next(type, config) {
|
|
|
124
142
|
case 0: return [4 /*yield*/, recursive(dir)];
|
|
125
143
|
case 1:
|
|
126
144
|
files = _a.sent();
|
|
127
|
-
return [2 /*return*/, files
|
|
128
|
-
|
|
129
|
-
return file.replace('.mdx', '').replace(dir, '').replace(/\\/g, '/').replace(/^\//, '');
|
|
130
|
-
})
|
|
131
|
-
.map(function (id) { return ({
|
|
132
|
-
id: id.split('/'),
|
|
145
|
+
return [2 /*return*/, files.map(function (file) { return ({
|
|
146
|
+
slug: getSlug(file, dir).split('/'),
|
|
133
147
|
}); })];
|
|
134
148
|
}
|
|
135
149
|
});
|
|
@@ -138,19 +152,27 @@ export function next(type, config) {
|
|
|
138
152
|
function renderPage(render) {
|
|
139
153
|
var _this = this;
|
|
140
154
|
return function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
141
|
-
var
|
|
155
|
+
var slug, file, files, content;
|
|
142
156
|
var _c, _d;
|
|
143
157
|
var params = _b.params;
|
|
144
158
|
return __generator(this, function (_e) {
|
|
145
159
|
switch (_e.label) {
|
|
146
160
|
case 0: return [4 /*yield*/, params];
|
|
147
161
|
case 1:
|
|
148
|
-
|
|
149
|
-
file = path.join(dir, "".concat(
|
|
150
|
-
return [4 /*yield*/,
|
|
162
|
+
slug = ((_d = (_c = (_e.sent())) === null || _c === void 0 ? void 0 : _c.slug) === null || _d === void 0 ? void 0 : _d.join('/')) || 'index';
|
|
163
|
+
file = path.join(dir, "".concat(slug, ".mdx"));
|
|
164
|
+
return [4 /*yield*/, recursive(dir)];
|
|
151
165
|
case 2:
|
|
166
|
+
files = _e.sent();
|
|
167
|
+
return [4 /*yield*/, getContent(file)];
|
|
168
|
+
case 3:
|
|
169
|
+
content = _e.sent();
|
|
170
|
+
if (!(!content && slug.endsWith('index'))) return [3 /*break*/, 5];
|
|
171
|
+
return [4 /*yield*/, Promise.all(files.map(function (file) { return getContent(file); }))];
|
|
172
|
+
case 4:
|
|
152
173
|
content = _e.sent();
|
|
153
|
-
|
|
174
|
+
_e.label = 5;
|
|
175
|
+
case 5: return [2 /*return*/, render({ type: type, config: config, content: content })];
|
|
154
176
|
}
|
|
155
177
|
});
|
|
156
178
|
}); };
|