@jpmorganchase/mosaic-plugins 0.1.0-beta.6 → 0.1.0-beta.7
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/CHANGELOG.md +21 -0
- package/dist/$AliasPlugin.js +6 -8
- package/dist/$AliasPlugin.js.map +1 -1
- package/dist/$CodeModPlugin.js +5 -7
- package/dist/$CodeModPlugin.js.map +1 -1
- package/dist/$RefPlugin.js +41 -43
- package/dist/$RefPlugin.js.map +1 -1
- package/dist/$TagPlugin.js +15 -19
- package/dist/$TagPlugin.js.map +1 -1
- package/dist/BreadcrumbsPlugin.js +6 -3
- package/dist/BreadcrumbsPlugin.js.map +1 -1
- package/dist/LazyPagePlugin.js +12 -14
- package/dist/LazyPagePlugin.js.map +1 -1
- package/dist/LocalFolderSavePlugin.js +48 -0
- package/dist/LocalFolderSavePlugin.js.map +1 -0
- package/dist/NextPrevPagePlugin.js +17 -17
- package/dist/NextPrevPagePlugin.js.map +1 -1
- package/dist/PagesWithoutFileExtPlugin.js +5 -7
- package/dist/PagesWithoutFileExtPlugin.js.map +1 -1
- package/dist/ReadingTimePlugin.mjs.map +1 -1
- package/dist/SearchIndexPlugin.mjs +268 -0
- package/dist/SearchIndexPlugin.mjs.map +1 -0
- package/dist/SharedConfigPlugin.js +6 -6
- package/dist/SharedConfigPlugin.js.map +1 -1
- package/dist/SidebarPlugin.js +58 -54
- package/dist/SidebarPlugin.js.map +1 -1
- package/dist/SiteMapPlugin.js +7 -9
- package/dist/SiteMapPlugin.js.map +1 -1
- package/dist/TableOfContentsPlugin.mjs +49 -58
- package/dist/TableOfContentsPlugin.mjs.map +1 -1
- package/package.json +16 -5
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _asyncToGenerator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _defineProperty(obj, key, value) {
|
|
31
|
+
if (key in obj) {
|
|
32
|
+
Object.defineProperty(obj, key, {
|
|
33
|
+
value: value,
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
obj[key] = value;
|
|
40
|
+
}
|
|
41
|
+
return obj;
|
|
42
|
+
}
|
|
43
|
+
function _objectSpread(target) {
|
|
44
|
+
for(var i = 1; i < arguments.length; i++){
|
|
45
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
46
|
+
var ownKeys = Object.keys(source);
|
|
47
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
48
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
49
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
ownKeys.forEach(function(key) {
|
|
53
|
+
_defineProperty(target, key, source[key]);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return target;
|
|
57
|
+
}
|
|
58
|
+
function ownKeys(object, enumerableOnly) {
|
|
59
|
+
var keys = Object.keys(object);
|
|
60
|
+
if (Object.getOwnPropertySymbols) {
|
|
61
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
62
|
+
if (enumerableOnly) {
|
|
63
|
+
symbols = symbols.filter(function(sym) {
|
|
64
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
keys.push.apply(keys, symbols);
|
|
68
|
+
}
|
|
69
|
+
return keys;
|
|
70
|
+
}
|
|
71
|
+
function _objectSpreadProps(target, source) {
|
|
72
|
+
source = source != null ? source : {};
|
|
73
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
74
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
75
|
+
} else {
|
|
76
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
77
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return target;
|
|
81
|
+
}
|
|
82
|
+
import regeneratorRuntime from "regenerator-runtime";
|
|
83
|
+
import { unified } from "unified";
|
|
84
|
+
import markdown from "remark-parse";
|
|
85
|
+
import remarkMdx from "remark-mdx";
|
|
86
|
+
import { visit } from "unist-util-visit";
|
|
87
|
+
/**
|
|
88
|
+
* Converts raw content string into an array of sentences suitable for inclusion
|
|
89
|
+
* in the search index
|
|
90
|
+
*
|
|
91
|
+
* @param options.content the raw content string
|
|
92
|
+
* @param options.title the title of the page (used for adding context to parse errors)
|
|
93
|
+
* @param options.maxLineLength the maximum length of a sentence (set this to match the
|
|
94
|
+
* "location" option in your Fuse.js configuration). Sentences longer than this value will be
|
|
95
|
+
* truncated.
|
|
96
|
+
* @param options.maxLineCount the maximum number of lines to include in the search index for
|
|
97
|
+
* each page. Pages with more lines than this value will be truncated.
|
|
98
|
+
* @returns array of sentence strings
|
|
99
|
+
*/ var optimizeContentForSearch = function() {
|
|
100
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(param) {
|
|
101
|
+
var content, title, maxLineLength, maxLineCount, processor, tree, sentences;
|
|
102
|
+
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
103
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
104
|
+
case 0:
|
|
105
|
+
content = param.content, title = param.title, maxLineLength = param.maxLineLength, maxLineCount = param.maxLineCount;
|
|
106
|
+
if (!(!content || content.length < 1)) {
|
|
107
|
+
_ctx.next = 3;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
return _ctx.abrupt("return", [
|
|
111
|
+
content
|
|
112
|
+
]);
|
|
113
|
+
case 3:
|
|
114
|
+
processor = unified().use(markdown).use(remarkMdx);
|
|
115
|
+
;
|
|
116
|
+
_ctx.prev = 5;
|
|
117
|
+
_ctx.next = 8;
|
|
118
|
+
return processor.parse(content);
|
|
119
|
+
case 8:
|
|
120
|
+
tree = _ctx.sent;
|
|
121
|
+
_ctx.next = 15;
|
|
122
|
+
break;
|
|
123
|
+
case 11:
|
|
124
|
+
_ctx.prev = 11;
|
|
125
|
+
_ctx.t0 = _ctx["catch"](5);
|
|
126
|
+
console.error("Search Index Plugin failed to parse content for ".concat(title), _ctx.t0.reason);
|
|
127
|
+
return _ctx.abrupt("return", []);
|
|
128
|
+
case 15:
|
|
129
|
+
sentences = [];
|
|
130
|
+
visit(tree, function(node) {
|
|
131
|
+
return node.type === "text" || node.type === "code";
|
|
132
|
+
}, function(node) {
|
|
133
|
+
if (maxLineLength) {
|
|
134
|
+
sentences.push(node.value.slice(0, maxLineLength));
|
|
135
|
+
} else {
|
|
136
|
+
sentences.push(node.value);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
if (!maxLineLength) {
|
|
140
|
+
_ctx.next = 19;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
return _ctx.abrupt("return", sentences.slice(0, maxLineCount));
|
|
144
|
+
case 19:
|
|
145
|
+
return _ctx.abrupt("return", sentences);
|
|
146
|
+
case 20:
|
|
147
|
+
case "end":
|
|
148
|
+
return _ctx.stop();
|
|
149
|
+
}
|
|
150
|
+
}, _callee, null, [
|
|
151
|
+
[
|
|
152
|
+
5,
|
|
153
|
+
11
|
|
154
|
+
]
|
|
155
|
+
]);
|
|
156
|
+
}));
|
|
157
|
+
return function optimizeContentForSearch(_) {
|
|
158
|
+
return _ref.apply(this, arguments);
|
|
159
|
+
};
|
|
160
|
+
}();
|
|
161
|
+
/**
|
|
162
|
+
* Creates a search-data.json file that contains all the information from a page that is required
|
|
163
|
+
* to generate a search index
|
|
164
|
+
*/ var SearchIndexPlugin = {
|
|
165
|
+
afterUpdate: function afterUpdate(mutableFilesystem, param, param1) {
|
|
166
|
+
var sharedFilesystem = param.sharedFilesystem, serialiser = param.serialiser, ignorePages = param.ignorePages, maxLineLength = param1.maxLineLength, maxLineCount = param1.maxLineCount, keys = param1.keys;
|
|
167
|
+
return _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() {
|
|
168
|
+
var pages, searchData;
|
|
169
|
+
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
170
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
171
|
+
case 0:
|
|
172
|
+
_ctx.t0 = Promise;
|
|
173
|
+
_ctx.next = 3;
|
|
174
|
+
return mutableFilesystem.promises.glob("**", {
|
|
175
|
+
onlyFiles: true,
|
|
176
|
+
ignore: ignorePages.map(function(ignore) {
|
|
177
|
+
return "**/".concat(ignore);
|
|
178
|
+
}),
|
|
179
|
+
cwd: "/"
|
|
180
|
+
});
|
|
181
|
+
case 3:
|
|
182
|
+
_ctx.t1 = _ctx.sent.map(function() {
|
|
183
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(pagePath) {
|
|
184
|
+
var deserialisedPage;
|
|
185
|
+
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
186
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
187
|
+
case 0:
|
|
188
|
+
_ctx.t0 = serialiser;
|
|
189
|
+
_ctx.t1 = pagePath;
|
|
190
|
+
_ctx.next = 4;
|
|
191
|
+
return mutableFilesystem.promises.readFile(pagePath);
|
|
192
|
+
case 4:
|
|
193
|
+
_ctx.t2 = _ctx.sent;
|
|
194
|
+
_ctx.next = 7;
|
|
195
|
+
return _ctx.t0.deserialise.call(_ctx.t0, _ctx.t1, _ctx.t2);
|
|
196
|
+
case 7:
|
|
197
|
+
deserialisedPage = _ctx.sent;
|
|
198
|
+
return _ctx.abrupt("return", deserialisedPage);
|
|
199
|
+
case 9:
|
|
200
|
+
case "end":
|
|
201
|
+
return _ctx.stop();
|
|
202
|
+
}
|
|
203
|
+
}, _callee);
|
|
204
|
+
}));
|
|
205
|
+
return function(pagePath) {
|
|
206
|
+
return _ref.apply(this, arguments);
|
|
207
|
+
};
|
|
208
|
+
}());
|
|
209
|
+
_ctx.next = 6;
|
|
210
|
+
return _ctx.t0.all.call(_ctx.t0, _ctx.t1);
|
|
211
|
+
case 6:
|
|
212
|
+
pages = _ctx.sent;
|
|
213
|
+
_ctx.next = 9;
|
|
214
|
+
return Promise.all(pages.map(function() {
|
|
215
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee(page) {
|
|
216
|
+
var content, defaultResults, extendedResults;
|
|
217
|
+
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
218
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
219
|
+
case 0:
|
|
220
|
+
_ctx.next = 2;
|
|
221
|
+
return optimizeContentForSearch({
|
|
222
|
+
content: page.content || "",
|
|
223
|
+
title: page.title || "",
|
|
224
|
+
maxLineLength: maxLineLength,
|
|
225
|
+
maxLineCount: maxLineCount
|
|
226
|
+
});
|
|
227
|
+
case 2:
|
|
228
|
+
content = _ctx.sent;
|
|
229
|
+
defaultResults = {
|
|
230
|
+
title: page.title,
|
|
231
|
+
content: content,
|
|
232
|
+
route: page.route
|
|
233
|
+
};
|
|
234
|
+
if (!(keys && keys.length > 0)) {
|
|
235
|
+
_ctx.next = 7;
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
extendedResults = keys.reduce(function(acc, key) {
|
|
239
|
+
return _objectSpreadProps(_objectSpread({}, acc), _defineProperty({}, key, page[key]));
|
|
240
|
+
}, {});
|
|
241
|
+
return _ctx.abrupt("return", _objectSpread({}, defaultResults, extendedResults));
|
|
242
|
+
case 7:
|
|
243
|
+
return _ctx.abrupt("return", defaultResults);
|
|
244
|
+
case 8:
|
|
245
|
+
case "end":
|
|
246
|
+
return _ctx.stop();
|
|
247
|
+
}
|
|
248
|
+
}, _callee);
|
|
249
|
+
}));
|
|
250
|
+
return function(page) {
|
|
251
|
+
return _ref.apply(this, arguments);
|
|
252
|
+
};
|
|
253
|
+
}()));
|
|
254
|
+
case 9:
|
|
255
|
+
searchData = _ctx.sent;
|
|
256
|
+
_ctx.next = 12;
|
|
257
|
+
return sharedFilesystem.promises.writeFile("/search-data.json", JSON.stringify(searchData));
|
|
258
|
+
case 12:
|
|
259
|
+
case "end":
|
|
260
|
+
return _ctx.stop();
|
|
261
|
+
}
|
|
262
|
+
}, _callee);
|
|
263
|
+
}))();
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
export default SearchIndexPlugin;
|
|
267
|
+
|
|
268
|
+
//# sourceMappingURL=SearchIndexPlugin.mjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/SearchIndexPlugin.mjs.ts"],"sourcesContent":["import { unified } from 'unified';\nimport markdown from 'remark-parse';\nimport remarkMdx from 'remark-mdx';\nimport { visit } from 'unist-util-visit';\nimport type { Node } from 'unist';\nimport type { Page, Plugin as PluginType } from '@jpmorganchase/mosaic-types';\n\ntype LeafNode = Node & {\n value: string;\n};\n\ninterface SearchIndexPluginOptions {\n maxLineLength?: number;\n maxLineCount?: number;\n keys?: string[];\n}\n\ninterface Optimization {\n content: string;\n title: string;\n maxLineCount: number;\n maxLineLength: number;\n}\n\n/**\n * Converts raw content string into an array of sentences suitable for inclusion\n * in the search index\n *\n * @param options.content the raw content string\n * @param options.title the title of the page (used for adding context to parse errors)\n * @param options.maxLineLength the maximum length of a sentence (set this to match the\n * \"location\" option in your Fuse.js configuration). Sentences longer than this value will be\n * truncated.\n * @param options.maxLineCount the maximum number of lines to include in the search index for\n * each page. Pages with more lines than this value will be truncated.\n * @returns array of sentence strings\n */\nconst optimizeContentForSearch = async ({\n content,\n title,\n maxLineLength,\n maxLineCount\n}: Optimization) => {\n if (!content || content.length < 1) return [content];\n const processor = unified().use(markdown).use(remarkMdx);\n let tree;\n\n try {\n tree = await processor.parse(content);\n } catch (err) {\n console.error(`Search Index Plugin failed to parse content for ${title}`, err.reason);\n return [];\n }\n\n const sentences: string[] = [];\n\n visit(\n tree,\n node => node.type === 'text' || node.type === 'code',\n (node: LeafNode) => {\n if (maxLineLength) {\n sentences.push(node.value.slice(0, maxLineLength));\n } else {\n sentences.push(node.value);\n }\n }\n );\n\n if (maxLineLength) {\n return sentences.slice(0, maxLineCount);\n }\n return sentences;\n};\n\n/**\n * Creates a search-data.json file that contains all the information from a page that is required\n * to generate a search index\n */\nconst SearchIndexPlugin: PluginType<Page, SearchIndexPluginOptions> = {\n async afterUpdate(\n mutableFilesystem,\n { sharedFilesystem, serialiser, ignorePages },\n { maxLineLength, maxLineCount, keys }\n ) {\n const pages = await Promise.all(\n (\n (await mutableFilesystem.promises.glob('**', {\n onlyFiles: true,\n ignore: ignorePages.map(ignore => `**/${ignore}`),\n cwd: '/'\n })) as string[]\n ).map(async pagePath => {\n const deserialisedPage = await serialiser.deserialise(\n pagePath,\n await mutableFilesystem.promises.readFile(pagePath)\n );\n return deserialisedPage;\n })\n );\n\n const searchData = await Promise.all(\n pages.map(async page => {\n const content = await optimizeContentForSearch({\n content: page.content || '',\n title: page.title || '',\n maxLineLength,\n maxLineCount\n });\n const defaultResults = {\n title: page.title,\n content,\n route: page.route\n };\n\n if (keys && keys.length > 0) {\n const extendedResults = keys.reduce((acc, key) => ({ ...acc, [key]: page[key] }), {});\n return { ...defaultResults, ...extendedResults };\n }\n\n return defaultResults;\n })\n );\n\n await sharedFilesystem.promises.writeFile('/search-data.json', JSON.stringify(searchData));\n }\n};\n\nexport default SearchIndexPlugin;\n"],"names":["unified","markdown","remarkMdx","visit","optimizeContentForSearch","content","title","maxLineLength","maxLineCount","processor","tree","sentences","length","use","parse","console","error","err","reason","node","type","push","value","slice","SearchIndexPlugin","afterUpdate","mutableFilesystem","sharedFilesystem","serialiser","ignorePages","keys","pages","searchData","Promise","promises","glob","onlyFiles","ignore","map","cwd","pagePath","deserialisedPage","readFile","deserialise","all","page","defaultResults","extendedResults","route","reduce","acc","key","writeFile","JSON","stringify"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,OAAO,QAAQ,SAAS,CAAC;AAClC,OAAOC,QAAQ,MAAM,cAAc,CAAC;AACpC,OAAOC,SAAS,MAAM,YAAY,CAAC;AACnC,SAASC,KAAK,QAAQ,kBAAkB,CAAC;AAqBzC;;;;;;;;;;;;CAYC,GACD,IAAMC,wBAAwB;eAAG,wDAAA,wBAKb;YAJlBC,OAAO,EACPC,KAAK,EACLC,aAAa,EACbC,YAAY,EAGNC,SAAS,EACXC,IAAI,EASFC,SAAS;;;;oBAhBfN,OAAO,SAAPA,OAAO,EACPC,KAAK,SAALA,KAAK,EACLC,aAAa,SAAbA,aAAa,EACbC,YAAY,SAAZA,YAAY;wBAER,CAAA,CAAA,CAACH,OAAO,IAAIA,OAAO,CAACO,MAAM,GAAG,CAAC,CAAA;;;;iDAAS;wBAACP,OAAO;qBAAC;;oBAC9CI,SAAS,GAAGT,OAAO,EAAE,CAACa,GAAG,CAACZ,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C,CAAA;;;;4CACnBmC,eAAe,GAAGjB,IAAI,CAACmB,MAAM,CAAC,SAACC,GAAG,EAAEC,GAAG;uDAAM,qCAAKD,GAAG,GAAE,oBAACC,GAAG,EAAGN,IAAI,CAACM,GAAG,CAAC,CAAA,CAAE;6CAAC,EAAE,EAAE,CAAC,CAAC;yEAC/E,kBAAKL,cAAc,EAAKC,eAAe,CAAE;;yEAG3CD,cAAc;;;;;;6BACtB,EAAA;4CAnBeD,IAAI;;;4BAmBlB,CACH;;wBArBKb,UAAU,YAqBf,CAAA;;+BAEKL,gBAAgB,CAACO,QAAQ,CAACkB,SAAS,CAAC,mBAAmB,EAAEC,IAAI,CAACC,SAAS,CAACtB,UAAU,CAAC,CAAC;;;;;;SAC3F,EAAA;KAAA;CACF,AAAC;AAEF,eAAeR,iBAAiB,CAAC"}
|
|
@@ -14,6 +14,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const flatten_1 = __importDefault(require("lodash/flatten"));
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
|
+
function createFileGlob(url, pageExtensions) {
|
|
18
|
+
if (pageExtensions.length === 1) {
|
|
19
|
+
return `${url}${pageExtensions[0]}`;
|
|
20
|
+
}
|
|
21
|
+
return `${url}{${pageExtensions.join(',')}}`;
|
|
22
|
+
}
|
|
17
23
|
/**
|
|
18
24
|
* Plugin that crawls the page hierarchy to find the closest `sharedConfig` from any parent index's page metadata.
|
|
19
25
|
* It then exports a JSON file (name: `options.filename`) into each directory with the merged config for that level
|
|
@@ -41,10 +47,4 @@ const SharedConfigPlugin = {
|
|
|
41
47
|
}
|
|
42
48
|
};
|
|
43
49
|
exports.default = SharedConfigPlugin;
|
|
44
|
-
function createFileGlob(url, pageExtensions) {
|
|
45
|
-
if (pageExtensions.length === 1) {
|
|
46
|
-
return `${url}${pageExtensions[0]}`;
|
|
47
|
-
}
|
|
48
|
-
return `${url}{${pageExtensions.join(',')}}`;
|
|
49
|
-
}
|
|
50
50
|
//# sourceMappingURL=SharedConfigPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharedConfigPlugin.js","sourceRoot":"","sources":["../src/SharedConfigPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,6DAAqC;AACrC,gDAAwB;AAExB;;;GAGG;AACH,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"SharedConfigPlugin.js","sourceRoot":"","sources":["../src/SharedConfigPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,6DAAqC;AACrC,gDAAwB;AAExB,SAAS,cAAc,CAAC,GAAG,EAAE,cAAc;IACzC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;QAC/B,OAAO,GAAG,GAAG,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;KACrC;IACD,OAAO,GAAG,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAC/C,CAAC;AAUD;;;GAGG;AACH,MAAM,kBAAkB,GAAkE;IAClF,WAAW,CACf,iBAAiB,EACjB,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,EACnD,OAAO;;YAEP,MAAM,SAAS,GAAG,MAAM,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CACrD,cAAc,CAAC,UAAU,EAAE,cAAc,CAAC,EAC1C;gBACE,MAAM,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAA,iBAAO,EAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC3F,GAAG,EAAE,GAAG;aACT,CACF,CAAC;YAEF,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;gBAChC,MAAM,gBAAgB,GAAG,cAAI,CAAC,IAAI,CAAC,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAErF,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,WAAW,CACvC,MAAM,CAAC,QAAQ,CAAC,EAChB,MAAM,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAC5D,CAAC;gBACF,IAAI,IAAI,CAAC,YAAY,EAAE;oBACrB,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;oBACzF,MAAM,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;iBACpE;qBAAM;oBACL,MAAM,OAAO,GAAG,cAAI,CAAC,OAAO,CAAC,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;oBAEpE,MAAM,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;iBAC7E;aACF;QACH,CAAC;KAAA;CACF,CAAC;AAEF,kBAAe,kBAAkB,CAAC"}
|
package/dist/SidebarPlugin.js
CHANGED
|
@@ -13,6 +13,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const path_1 = __importDefault(require("path"));
|
|
16
|
+
function createFileGlob(patterns, pageExtensions) {
|
|
17
|
+
if (Array.isArray(patterns)) {
|
|
18
|
+
return patterns.map(pattern => createFileGlob(pattern, pageExtensions));
|
|
19
|
+
}
|
|
20
|
+
if (pageExtensions.length === 1) {
|
|
21
|
+
return `${patterns}${pageExtensions[0]}`;
|
|
22
|
+
}
|
|
23
|
+
return `${patterns}{${pageExtensions.join(',')}}`;
|
|
24
|
+
}
|
|
25
|
+
function isSubfolderIndex(page, dirName) {
|
|
26
|
+
return page.fullPath.split('/').length === String(dirName).split('/').length + 2;
|
|
27
|
+
}
|
|
28
|
+
function sortFn(pageA, pageB, dirName) {
|
|
29
|
+
// Always pin /index to the front
|
|
30
|
+
const route = `${dirName}/index`;
|
|
31
|
+
if (pageA.route === route) {
|
|
32
|
+
return -1;
|
|
33
|
+
}
|
|
34
|
+
if (pageB.route === route) {
|
|
35
|
+
return 1;
|
|
36
|
+
}
|
|
37
|
+
return ((pageB.sidebar && pageB.sidebar.priority ? pageB.sidebar.priority : -1) -
|
|
38
|
+
(pageA.sidebar && pageA.sidebar.priority ? pageA.sidebar.priority : -1));
|
|
39
|
+
}
|
|
40
|
+
function filterFn(page) {
|
|
41
|
+
return !(page.sidebar && page.sidebar.exclude);
|
|
42
|
+
}
|
|
16
43
|
/**
|
|
17
44
|
* Sorts the pages in a folder by priority and then exports a JSON file (name: `options.filename`) with the
|
|
18
45
|
* sidebar tree from that directory downwards and adds sidebar data into frontmatter for each page.
|
|
@@ -20,33 +47,12 @@ const path_1 = __importDefault(require("path"));
|
|
|
20
47
|
const SidebarPlugin = {
|
|
21
48
|
$beforeSend(mutableFilesystem, { config, serialiser, ignorePages, pageExtensions }, options) {
|
|
22
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const dirs = yield mutableFilesystem.promises.glob('**', {
|
|
24
|
-
onlyDirectories: true,
|
|
25
|
-
cwd: '/'
|
|
26
|
-
});
|
|
27
|
-
for (const dirName of dirs) {
|
|
28
|
-
const sidebarFilePath = path_1.default.posix.join(String(dirName), options.filename);
|
|
29
|
-
const pages = (yield Promise.all((yield mutableFilesystem.promises.glob(createFileGlob(['*', '*/index'], pageExtensions), {
|
|
30
|
-
onlyFiles: true,
|
|
31
|
-
cwd: String(dirName),
|
|
32
|
-
ignore: ignorePages.map(ignore => `**/${ignore}`)
|
|
33
|
-
})).map((pagePath) => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
return yield serialiser.deserialise(pagePath, yield mutableFilesystem.promises.readFile(pagePath));
|
|
35
|
-
}))))
|
|
36
|
-
.filter(page => filterFn(page))
|
|
37
|
-
.sort((pageA, pageB) => sortFn(pageA, pageB, dirName));
|
|
38
|
-
for (let i = 0; i < pages.length; i++) {
|
|
39
|
-
setPageRefs(sidebarFilePath, pages[i], i);
|
|
40
|
-
setChildPageRefs(pages[i], dirName, i, sidebarFilePath);
|
|
41
|
-
addSidebarDataToFrontmatter(pages[i], dirName);
|
|
42
|
-
}
|
|
43
|
-
yield mutableFilesystem.promises.writeFile(sidebarFilePath, '[]');
|
|
44
|
-
}
|
|
45
50
|
function setPageRefs(sidebarFilePath, page, i) {
|
|
46
51
|
config.setRef(sidebarFilePath, ['pages', `${i}`, 'id', '$ref'], `${page.fullPath}#/route`);
|
|
47
|
-
page.sidebar && page.sidebar.label
|
|
48
|
-
?
|
|
49
|
-
:
|
|
52
|
+
const label = page.sidebar && page.sidebar.label
|
|
53
|
+
? `${page.fullPath}#/sidebar/label`
|
|
54
|
+
: `${page.fullPath}#/title`;
|
|
55
|
+
config.setRef(sidebarFilePath, ['pages', `${i}`, 'name', '$ref'], label);
|
|
50
56
|
config.setRef(sidebarFilePath, ['pages', `${i}`, 'data', 'link', '$ref'], `${page.fullPath}#/route`);
|
|
51
57
|
}
|
|
52
58
|
function setChildPageRefs(page, dirName, i, sidebarFilePath) {
|
|
@@ -59,8 +65,9 @@ const SidebarPlugin = {
|
|
|
59
65
|
cwd: String(childDirName),
|
|
60
66
|
ignore: ignorePages.map(ignore => `**/${ignore}`)
|
|
61
67
|
})).map((pagePath) => __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
const deserialisedPage = yield serialiser.deserialise(pagePath, yield mutableFilesystem.promises.readFile(pagePath));
|
|
69
|
+
return deserialisedPage;
|
|
70
|
+
})))).filter(filterPage => filterFn(filterPage));
|
|
64
71
|
if (childPages.length > 1) {
|
|
65
72
|
for (let j = 1; j < childPages.length; j++) {
|
|
66
73
|
config.setRef(sidebarFilePath, ['pages', `${i}`, 'childNodes', `${j - 1}`, '$ref'], `${childNodeSidebarPath}#/pages/${j}`);
|
|
@@ -73,37 +80,34 @@ const SidebarPlugin = {
|
|
|
73
80
|
const dirNameLevels = String(dirName)
|
|
74
81
|
.split('/')
|
|
75
82
|
.filter(level => level);
|
|
76
|
-
const sidebarRootDir =
|
|
83
|
+
const sidebarRootDir = path_1.default.posix.join('/', ...dirNameLevels.slice(0, dirNameLevels.length < 3 ? dirNameLevels.length : 3), '/');
|
|
77
84
|
config.setRef(String(page.fullPath), ['sidebarData', '$ref'], path_1.default.posix.join(String(sidebarRootDir), options.filename, '#', 'pages'));
|
|
78
85
|
}
|
|
86
|
+
const dirs = yield mutableFilesystem.promises.glob('**', {
|
|
87
|
+
onlyDirectories: true,
|
|
88
|
+
cwd: '/'
|
|
89
|
+
});
|
|
90
|
+
for (const dirName of dirs) {
|
|
91
|
+
const sidebarFilePath = path_1.default.posix.join(String(dirName), options.filename);
|
|
92
|
+
const pages = (yield Promise.all((yield mutableFilesystem.promises.glob(createFileGlob(['*', '*/index'], pageExtensions), {
|
|
93
|
+
onlyFiles: true,
|
|
94
|
+
cwd: String(dirName),
|
|
95
|
+
ignore: ignorePages.map(ignore => `**/${ignore}`)
|
|
96
|
+
})).map((pagePath) => __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
const deserialisedPage = yield serialiser.deserialise(pagePath, yield mutableFilesystem.promises.readFile(pagePath));
|
|
98
|
+
return deserialisedPage;
|
|
99
|
+
}))))
|
|
100
|
+
.filter(page => filterFn(page))
|
|
101
|
+
.sort((pageA, pageB) => sortFn(pageA, pageB, dirName));
|
|
102
|
+
for (let i = 0; i < pages.length; i++) {
|
|
103
|
+
setPageRefs(sidebarFilePath, pages[i], i);
|
|
104
|
+
setChildPageRefs(pages[i], dirName, i, sidebarFilePath);
|
|
105
|
+
addSidebarDataToFrontmatter(pages[i], dirName);
|
|
106
|
+
}
|
|
107
|
+
yield mutableFilesystem.promises.writeFile(sidebarFilePath, '[]');
|
|
108
|
+
}
|
|
79
109
|
});
|
|
80
110
|
}
|
|
81
111
|
};
|
|
82
112
|
exports.default = SidebarPlugin;
|
|
83
|
-
function createFileGlob(patterns, pageExtensions) {
|
|
84
|
-
if (Array.isArray(patterns)) {
|
|
85
|
-
return patterns.map(pattern => createFileGlob(pattern, pageExtensions));
|
|
86
|
-
}
|
|
87
|
-
if (pageExtensions.length === 1) {
|
|
88
|
-
return `${patterns}${pageExtensions[0]}`;
|
|
89
|
-
}
|
|
90
|
-
return `${patterns}{${pageExtensions.join(',')}}`;
|
|
91
|
-
}
|
|
92
|
-
function isSubfolderIndex(page, dirName) {
|
|
93
|
-
return page.fullPath.split('/').length == String(dirName).split('/').length + 2;
|
|
94
|
-
}
|
|
95
|
-
function sortFn(pageA, pageB, dirName) {
|
|
96
|
-
// Always pin /index to the front
|
|
97
|
-
if (pageA.route === dirName + '/index') {
|
|
98
|
-
return -1;
|
|
99
|
-
}
|
|
100
|
-
if (pageB.route === dirName + '/index') {
|
|
101
|
-
return 1;
|
|
102
|
-
}
|
|
103
|
-
return ((pageB.sidebar && pageB.sidebar.priority ? pageB.sidebar.priority : -1) -
|
|
104
|
-
(pageA.sidebar && pageA.sidebar.priority ? pageA.sidebar.priority : -1));
|
|
105
|
-
}
|
|
106
|
-
function filterFn(page) {
|
|
107
|
-
return !(page.sidebar && page.sidebar.exclude);
|
|
108
|
-
}
|
|
109
113
|
//# sourceMappingURL=SidebarPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SidebarPlugin.js","sourceRoot":"","sources":["../src/SidebarPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gDAAwB;
|
|
1
|
+
{"version":3,"file":"SidebarPlugin.js","sourceRoot":"","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AC,OAAO,CAAC;oBACpB,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,MAAM,EAAE,CAAC;iBAClD,CACF,CACF,CAAC,GAAG,CAAC,CAAM,QAAQ,EAAC,EAAE;oBACrB,MAAM,gBAAgB,GAAG,MAAM,UAAU,CAAC,WAAW,CACnD,QAAQ,EACR,MAAM,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACpD,CAAC;oBACF,OAAO,gBAAgB,CAAC;gBAC1B,CAAC,CAAA,CAAC,CACH,CACF;qBACE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;qBAC9B,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;gBAEzD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBACrC,WAAW,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;oBAC1C,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,eAAe,CAAC,CAAC;oBACxD,2BAA2B,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;iBAChD;gBACD,MAAM,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;aACnE;QACH,CAAC;KAAA;CACF,CAAC;AACJ,kBAAe,aAAa,CAAC"}
|
package/dist/SiteMapPlugin.js
CHANGED
|
@@ -11,22 +11,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const SiteMapPlugin = {
|
|
13
13
|
// Merge together all of the individual sitemaps from each source
|
|
14
|
-
afterUpdate(
|
|
14
|
+
afterUpdate(_, { sharedFilesystem, globalConfig }) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
if (!Array.isArray(globalConfig.data.sitemaps)) {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
.join('') +
|
|
25
|
-
'\n</urlset>');
|
|
19
|
+
const urls = globalConfig.data.sitemaps.map(items => items
|
|
20
|
+
.map(item => `\t<url>\n\t\t<loc>${String(item)}</loc>\n\t\t<changefreq>weekly</changefreq>\n\t\t<priority>0.5</priority>\n\t</url>`)
|
|
21
|
+
.join('\n'));
|
|
22
|
+
const urlSet = `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n ${urls}\n\n</urlset>`;
|
|
23
|
+
yield sharedFilesystem.promises.writeFile('/sitemap.xml', urlSet);
|
|
26
24
|
});
|
|
27
25
|
},
|
|
28
26
|
// Store a sitemap for just this source
|
|
29
|
-
$beforeSend(mutableFilesystem, { config, ignorePages }
|
|
27
|
+
$beforeSend(mutableFilesystem, { config, ignorePages }) {
|
|
30
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
29
|
config.setData({
|
|
32
30
|
sitemaps: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SiteMapPlugin.js","sourceRoot":"","sources":["../src/SiteMapPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"SiteMapPlugin.js","sourceRoot":"","sources":["../src/SiteMapPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;AAMA,MAAM,aAAa,GAAgF;IACjG,iEAAiE;IAC3D,WAAW,CAAC,CAAC,EAAE,EAAE,gBAAgB,EAAE,YAAY,EAAE;;YACrD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAC9C,OAAO;aACR;YAED,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAClD,KAAK;iBACF,GAAG,CACF,IAAI,CAAC,EAAE,CACL,qBAAqB,MAAM,CACzB,IAAI,CACL,qFAAqF,CACzF;iBACA,IAAI,CAAC,IAAI,CAAC,CACd,CAAC;YAEF,MAAM,MAAM,GAAG,kEAAkE,IAAI,eAAe,CAAC;YACrG,MAAM,gBAAgB,CAAC,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QACpE,CAAC;KAAA;IACD,uCAAuC;IACjC,WAAW,CAAC,iBAAiB,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;;YAC1D,MAAM,CAAC,OAAO,CAAC;gBACb,QAAQ,EAAE;oBACR,CAAC,MAAM,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE;wBAC3C,SAAS,EAAE,IAAI;wBACf,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,MAAM,EAAE,CAAC;wBACjD,GAAG,EAAE,GAAG;qBACT,CAAC,CAAkB;iBACrB;aACF,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC;AAEF,kBAAe,aAAa,CAAC"}
|