@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
|
@@ -27,109 +27,100 @@ function _asyncToGenerator(fn) {
|
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
function _throw(e) {
|
|
31
|
-
throw e;
|
|
32
|
-
}
|
|
33
30
|
import regeneratorRuntime from "regenerator-runtime";
|
|
34
31
|
import Slugger from "github-slugger";
|
|
35
|
-
import
|
|
36
|
-
import markdown from "remark-parse";
|
|
32
|
+
import remarkParse from "remark-parse";
|
|
37
33
|
import { unified } from "unified";
|
|
38
|
-
import
|
|
34
|
+
import remarkStringify from "remark-stringify";
|
|
35
|
+
import remarkHeadings from "@vcarl/remark-headings";
|
|
39
36
|
/**
|
|
40
37
|
* Calculates table of contents from page headings
|
|
41
38
|
*/ var TableOfContentsPlugin = {
|
|
42
|
-
$afterSource: function $afterSource(pages, _
|
|
43
|
-
var
|
|
39
|
+
$afterSource: function $afterSource(pages, _, param) {
|
|
40
|
+
var minRank = param.minRank, maxRank = param.maxRank;
|
|
44
41
|
return _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() {
|
|
45
|
-
var processor, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, page, slugger,
|
|
42
|
+
var processor, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, page, slugger, vfile, headings, items;
|
|
46
43
|
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
47
44
|
while(1)switch(_ctx.prev = _ctx.next){
|
|
48
45
|
case 0:
|
|
49
|
-
|
|
50
|
-
return node.type === "heading" && isHeadingInRange(node);
|
|
51
|
-
};
|
|
52
|
-
isHeadingInRange = function _isHeadingInRange(node) {
|
|
53
|
-
var depth = node.depth;
|
|
54
|
-
if (depth < minRank || depth > maxRank) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
return true;
|
|
58
|
-
};
|
|
59
|
-
processor = unified().use(markdown);
|
|
46
|
+
processor = unified().use(remarkParse).use(remarkStringify).use(remarkHeadings);
|
|
60
47
|
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
61
|
-
_ctx.prev =
|
|
48
|
+
_ctx.prev = 2;
|
|
62
49
|
_iterator = pages[Symbol.iterator]();
|
|
63
|
-
case
|
|
50
|
+
case 4:
|
|
64
51
|
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
|
|
65
|
-
_ctx.next =
|
|
52
|
+
_ctx.next = 17;
|
|
66
53
|
break;
|
|
67
54
|
}
|
|
68
55
|
page = _step.value;
|
|
69
56
|
slugger = new Slugger();
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
57
|
+
if (!page.content) {
|
|
58
|
+
_ctx.next = 14;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
_ctx.next = 10;
|
|
62
|
+
return processor.process(page.content);
|
|
63
|
+
case 10:
|
|
64
|
+
vfile = _ctx.sent;
|
|
65
|
+
headings = vfile.data.headings;
|
|
66
|
+
items = headings.filter(function(heading) {
|
|
67
|
+
return heading.depth >= minRank && heading.depth <= maxRank;
|
|
68
|
+
}).map(function(validHeading) {
|
|
69
|
+
var text = validHeading.value.trim();
|
|
70
|
+
return {
|
|
71
|
+
level: validHeading.depth,
|
|
81
72
|
id: slugger.slug(text),
|
|
82
73
|
text: text
|
|
83
|
-
}
|
|
74
|
+
};
|
|
84
75
|
});
|
|
85
76
|
page.tableOfContents = items;
|
|
86
|
-
case
|
|
77
|
+
case 14:
|
|
87
78
|
_iteratorNormalCompletion = true;
|
|
88
|
-
_ctx.next =
|
|
79
|
+
_ctx.next = 4;
|
|
89
80
|
break;
|
|
90
|
-
case
|
|
91
|
-
_ctx.next =
|
|
81
|
+
case 17:
|
|
82
|
+
_ctx.next = 23;
|
|
92
83
|
break;
|
|
93
|
-
case
|
|
94
|
-
_ctx.prev =
|
|
95
|
-
_ctx.t0 = _ctx["catch"](
|
|
84
|
+
case 19:
|
|
85
|
+
_ctx.prev = 19;
|
|
86
|
+
_ctx.t0 = _ctx["catch"](2);
|
|
96
87
|
_didIteratorError = true;
|
|
97
88
|
_iteratorError = _ctx.t0;
|
|
98
|
-
case
|
|
89
|
+
case 23:
|
|
90
|
+
_ctx.prev = 23;
|
|
99
91
|
_ctx.prev = 24;
|
|
100
|
-
_ctx.prev = 25;
|
|
101
92
|
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
102
93
|
_iterator.return();
|
|
103
94
|
}
|
|
104
|
-
case
|
|
105
|
-
_ctx.prev =
|
|
95
|
+
case 26:
|
|
96
|
+
_ctx.prev = 26;
|
|
106
97
|
if (!_didIteratorError) {
|
|
107
|
-
_ctx.next =
|
|
98
|
+
_ctx.next = 29;
|
|
108
99
|
break;
|
|
109
100
|
}
|
|
110
101
|
throw _iteratorError;
|
|
102
|
+
case 29:
|
|
103
|
+
return _ctx.finish(26);
|
|
111
104
|
case 30:
|
|
112
|
-
return _ctx.finish(
|
|
105
|
+
return _ctx.finish(23);
|
|
113
106
|
case 31:
|
|
114
|
-
return _ctx.finish(24);
|
|
115
|
-
case 32:
|
|
116
107
|
return _ctx.abrupt("return", pages);
|
|
117
|
-
case
|
|
108
|
+
case 32:
|
|
118
109
|
case "end":
|
|
119
110
|
return _ctx.stop();
|
|
120
111
|
}
|
|
121
112
|
}, _callee, null, [
|
|
122
113
|
[
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
114
|
+
2,
|
|
115
|
+
19,
|
|
116
|
+
23,
|
|
117
|
+
31
|
|
127
118
|
],
|
|
128
119
|
[
|
|
129
|
-
|
|
120
|
+
24,
|
|
130
121
|
,
|
|
131
|
-
|
|
132
|
-
|
|
122
|
+
26,
|
|
123
|
+
30
|
|
133
124
|
]
|
|
134
125
|
]);
|
|
135
126
|
}))();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/TableOfContentsPlugin.mjs.ts"],"sourcesContent":["import type { Page, Plugin as PluginType } from '@jpmorganchase/mosaic-types';\nimport Slugger from 'github-slugger';\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/TableOfContentsPlugin.mjs.ts"],"sourcesContent":["import type { Page, Plugin as PluginType } from '@jpmorganchase/mosaic-types';\nimport Slugger from 'github-slugger';\nimport remarkParse from 'remark-parse';\nimport { unified } from 'unified';\nimport remarkStringify from 'remark-stringify';\nimport remarkHeadings from '@vcarl/remark-headings';\nimport type { Heading as MarkdownHeading } from 'mdast';\n\ntype TOCItem = { level: number; id: string; text: string };\n\ninterface TableOfContentsPluginPage extends Page {\n tableOfContents?: TOCItem[];\n}\ntype Rank = MarkdownHeading['depth'];\ninterface TableOfContentsPluginOptions {\n minRank: Rank;\n maxRank: Rank;\n}\n\n/**\n * Calculates table of contents from page headings\n */\nconst TableOfContentsPlugin: PluginType<TableOfContentsPluginPage, TableOfContentsPluginOptions> = {\n async $afterSource(pages, _, { minRank, maxRank }) {\n const processor = unified().use(remarkParse).use(remarkStringify).use(remarkHeadings);\n for (const page of pages) {\n const slugger = new Slugger();\n if (page.content) {\n const vfile = await processor.process(page.content);\n const headings = vfile.data.headings as [{ depth: number; value: string }];\n const items: TOCItem[] = headings\n .filter(heading => heading.depth >= minRank && heading.depth <= maxRank)\n .map(validHeading => {\n const text = validHeading.value.trim();\n return {\n level: validHeading.depth,\n id: slugger.slug(text),\n text\n };\n });\n page.tableOfContents = items;\n }\n }\n\n return pages;\n }\n};\n\nexport default TableOfContentsPlugin;\n"],"names":["Slugger","remarkParse","unified","remarkStringify","remarkHeadings","TableOfContentsPlugin","$afterSource","pages","_","minRank","maxRank","processor","page","slugger","vfile","headings","items","use","content","process","data","filter","heading","depth","map","validHeading","text","value","trim","level","id","slug","tableOfContents"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAOA,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAOC,WAAW,MAAM,cAAc,CAAC;AACvC,SAASC,OAAO,QAAQ,SAAS,CAAC;AAClC,OAAOC,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAOC,cAAc,MAAM,wBAAwB,CAAC;AAcpD;;CAEC,GACD,IAAMC,qBAAqB,GAAwE;IAC3FC,YAA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AAC;yBACH,CAAC,CAAC;wBACLd,IAAI,CAACoB,eAAe,GAAGhB,KAAK,CAAC;;wBAf5B,yBAAU;;;;;;;;;wBAAV,iBAAU;wBAAV,cAAU;;;;6BAAV,yBAAU,IAAV,SAAU;4BAAV,SAAU;;;;4BAAV,CAAA,iBAAU;;;;8BAAV,cAAU;;;;;;qDAmBRT,KAAK;;;;;;;;;;;;;;;;;;;SACb,EAAA;KAAA;CACF,AAAC;AAEF,eAAeF,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jpmorganchase/mosaic-plugins",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.7",
|
|
4
4
|
"author": "",
|
|
5
5
|
"description": "Mosaic plugins for core file system",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "yarn clean && tsc && swc
|
|
15
|
+
"build": "yarn clean && tsc && swc src -d dist && renamer --find \".mjs.js\" --replace \".mjs\" \"dist/*.mjs.js\" && renamer --find \".mjs.js.map\" --replace \".mjs.map\" \"dist/*.mjs.js.map\"",
|
|
16
16
|
"clean": "rm -fr dist"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
@@ -22,17 +22,28 @@
|
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@swc/cli": "^0.1.55",
|
|
24
24
|
"@swc/core": "^1.2.237",
|
|
25
|
+
"@types/fs-extra": "^9.0.13",
|
|
25
26
|
"renamer": "^4.0.0"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"@apidevtools/json-schema-ref-parser": "^9.0.9",
|
|
29
|
-
"@jpmorganchase/mosaic-
|
|
30
|
+
"@jpmorganchase/mosaic-serialisers": "^0.1.0-beta.7",
|
|
31
|
+
"@jpmorganchase/mosaic-source-git-repo": "^0.1.0-beta.7",
|
|
32
|
+
"@jpmorganchase/mosaic-source-local-folder": "^0.1.0-beta.7",
|
|
33
|
+
"@jpmorganchase/mosaic-types": "^0.1.0-beta.7",
|
|
30
34
|
"@types/github-slugger": "^1.3.0",
|
|
35
|
+
"@vcarl/remark-headings": "^0.1.0",
|
|
36
|
+
"fs-extra": "^10.1.0",
|
|
31
37
|
"github-slugger": "^1.4.0",
|
|
32
|
-
"hast-util-to-string": "^2.0.0",
|
|
33
38
|
"lodash": "^4.17.21",
|
|
34
39
|
"memfs": "^3.3.0",
|
|
35
40
|
"reading-time": "^1.5.0",
|
|
36
|
-
"
|
|
41
|
+
"remark-mdx": "^2.1.5",
|
|
42
|
+
"remark-parse": "^10.0.1",
|
|
43
|
+
"remark-stringify": "^10.0.2",
|
|
44
|
+
"rxjs": "^7.5.5",
|
|
45
|
+
"unified": "^10.1.2",
|
|
46
|
+
"unist-util-visit": "^4.1.1",
|
|
47
|
+
"uuid": "^7.0.3"
|
|
37
48
|
}
|
|
38
49
|
}
|