@jpmorganchase/mosaic-plugins 0.1.0-beta.7 → 0.1.0-beta.71
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/$AliasPlugin.d.ts +10 -0
- package/dist/$AliasPlugin.js +34 -46
- package/dist/$AliasPlugin.js.map +1 -1
- package/dist/$CodeModPlugin.d.ts +7 -0
- package/dist/$CodeModPlugin.js +12 -28
- package/dist/$CodeModPlugin.js.map +1 -1
- package/dist/$RefPlugin.d.ts +31 -0
- package/dist/$RefPlugin.js +109 -108
- package/dist/$RefPlugin.js.map +1 -1
- package/dist/$TagPlugin.d.ts +28 -0
- package/dist/$TagPlugin.js +24 -44
- package/dist/$TagPlugin.js.map +1 -1
- package/dist/BreadcrumbsPlugin.d.ts +19 -0
- package/dist/BreadcrumbsPlugin.js +78 -34
- package/dist/BreadcrumbsPlugin.js.map +1 -1
- package/dist/BrokenLinksPlugin.d.ts +10 -0
- package/dist/BrokenLinksPlugin.js +80 -0
- package/dist/BrokenLinksPlugin.js.map +1 -0
- package/dist/FragmentPlugin.d.ts +3 -0
- package/dist/FragmentPlugin.js +61 -0
- package/dist/FragmentPlugin.js.map +1 -0
- package/dist/LazyPagePlugin.d.ts +14 -0
- package/dist/LazyPagePlugin.js +46 -79
- package/dist/LazyPagePlugin.js.map +1 -1
- package/dist/PagesWithoutFileExtPlugin.d.ts +9 -0
- package/dist/PagesWithoutFileExtPlugin.js +14 -29
- package/dist/PagesWithoutFileExtPlugin.js.map +1 -1
- package/dist/PropsTablePlugin.d.ts +6 -0
- package/dist/PropsTablePlugin.js +88 -0
- package/dist/PropsTablePlugin.js.map +1 -0
- package/dist/PublicAssetsPlugin.d.ts +18 -0
- package/dist/PublicAssetsPlugin.js +28 -0
- package/dist/PublicAssetsPlugin.js.map +1 -0
- package/dist/ReadingTimePlugin.d.ts +10 -0
- package/dist/ReadingTimePlugin.js +39 -0
- package/dist/ReadingTimePlugin.js.map +1 -0
- package/dist/SearchIndexPlugin.d.ts +56 -0
- package/dist/SearchIndexPlugin.js +154 -0
- package/dist/SearchIndexPlugin.js.map +1 -0
- package/dist/SharedConfigPlugin.d.ts +14 -0
- package/dist/SharedConfigPlugin.js +124 -32
- package/dist/SharedConfigPlugin.js.map +1 -1
- package/dist/SidebarPlugin.d.ts +44 -0
- package/dist/SidebarPlugin.js +235 -88
- package/dist/SidebarPlugin.js.map +1 -1
- package/dist/SiteMapPlugin.d.ts +9 -0
- package/dist/SiteMapPlugin.js +20 -34
- package/dist/SiteMapPlugin.js.map +1 -1
- package/dist/TableOfContentsPlugin.d.ts +20 -0
- package/dist/TableOfContentsPlugin.js +44 -0
- package/dist/TableOfContentsPlugin.js.map +1 -0
- package/dist/utils/PluginError.d.ts +7 -0
- package/dist/utils/PluginError.js +13 -0
- package/dist/utils/PluginError.js.map +1 -0
- package/dist/utils/createPageTest.d.ts +1 -0
- package/dist/utils/createPageTest.js +8 -0
- package/dist/utils/createPageTest.js.map +1 -0
- package/dist/utils/mergePageContent.d.ts +16 -0
- package/dist/utils/mergePageContent.js +23 -0
- package/dist/utils/mergePageContent.js.map +1 -0
- package/dist/utils/normaliseRefs.d.ts +1 -0
- package/dist/utils/normaliseRefs.js +52 -69
- package/dist/utils/normaliseRefs.js.map +1 -1
- package/dist/utils/sortSidebarData.d.ts +19 -0
- package/dist/utils/sortSidebarData.js +35 -0
- package/dist/utils/sortSidebarData.js.map +1 -0
- package/package.json +42 -19
- package/CHANGELOG.md +0 -79
- package/dist/LocalFolderSavePlugin.js +0 -48
- package/dist/LocalFolderSavePlugin.js.map +0 -1
- package/dist/NextPrevPagePlugin.js +0 -63
- package/dist/NextPrevPagePlugin.js.map +0 -1
- package/dist/ReadingTimePlugin.mjs +0 -119
- package/dist/ReadingTimePlugin.mjs.map +0 -1
- package/dist/SearchIndexPlugin.mjs +0 -268
- package/dist/SearchIndexPlugin.mjs.map +0 -1
- package/dist/TableOfContentsPlugin.mjs +0 -131
- package/dist/TableOfContentsPlugin.mjs.map +0 -1
|
@@ -1,131 +0,0 @@
|
|
|
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
|
-
import regeneratorRuntime from "regenerator-runtime";
|
|
31
|
-
import Slugger from "github-slugger";
|
|
32
|
-
import remarkParse from "remark-parse";
|
|
33
|
-
import { unified } from "unified";
|
|
34
|
-
import remarkStringify from "remark-stringify";
|
|
35
|
-
import remarkHeadings from "@vcarl/remark-headings";
|
|
36
|
-
/**
|
|
37
|
-
* Calculates table of contents from page headings
|
|
38
|
-
*/ var TableOfContentsPlugin = {
|
|
39
|
-
$afterSource: function $afterSource(pages, _, param) {
|
|
40
|
-
var minRank = param.minRank, maxRank = param.maxRank;
|
|
41
|
-
return _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() {
|
|
42
|
-
var processor, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, page, slugger, vfile, headings, items;
|
|
43
|
-
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
44
|
-
while(1)switch(_ctx.prev = _ctx.next){
|
|
45
|
-
case 0:
|
|
46
|
-
processor = unified().use(remarkParse).use(remarkStringify).use(remarkHeadings);
|
|
47
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
48
|
-
_ctx.prev = 2;
|
|
49
|
-
_iterator = pages[Symbol.iterator]();
|
|
50
|
-
case 4:
|
|
51
|
-
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
|
|
52
|
-
_ctx.next = 17;
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
page = _step.value;
|
|
56
|
-
slugger = new Slugger();
|
|
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,
|
|
72
|
-
id: slugger.slug(text),
|
|
73
|
-
text: text
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
page.tableOfContents = items;
|
|
77
|
-
case 14:
|
|
78
|
-
_iteratorNormalCompletion = true;
|
|
79
|
-
_ctx.next = 4;
|
|
80
|
-
break;
|
|
81
|
-
case 17:
|
|
82
|
-
_ctx.next = 23;
|
|
83
|
-
break;
|
|
84
|
-
case 19:
|
|
85
|
-
_ctx.prev = 19;
|
|
86
|
-
_ctx.t0 = _ctx["catch"](2);
|
|
87
|
-
_didIteratorError = true;
|
|
88
|
-
_iteratorError = _ctx.t0;
|
|
89
|
-
case 23:
|
|
90
|
-
_ctx.prev = 23;
|
|
91
|
-
_ctx.prev = 24;
|
|
92
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
93
|
-
_iterator.return();
|
|
94
|
-
}
|
|
95
|
-
case 26:
|
|
96
|
-
_ctx.prev = 26;
|
|
97
|
-
if (!_didIteratorError) {
|
|
98
|
-
_ctx.next = 29;
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
throw _iteratorError;
|
|
102
|
-
case 29:
|
|
103
|
-
return _ctx.finish(26);
|
|
104
|
-
case 30:
|
|
105
|
-
return _ctx.finish(23);
|
|
106
|
-
case 31:
|
|
107
|
-
return _ctx.abrupt("return", pages);
|
|
108
|
-
case 32:
|
|
109
|
-
case "end":
|
|
110
|
-
return _ctx.stop();
|
|
111
|
-
}
|
|
112
|
-
}, _callee, null, [
|
|
113
|
-
[
|
|
114
|
-
2,
|
|
115
|
-
19,
|
|
116
|
-
23,
|
|
117
|
-
31
|
|
118
|
-
],
|
|
119
|
-
[
|
|
120
|
-
24,
|
|
121
|
-
,
|
|
122
|
-
26,
|
|
123
|
-
30
|
|
124
|
-
]
|
|
125
|
-
]);
|
|
126
|
-
}))();
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
export default TableOfContentsPlugin;
|
|
130
|
-
|
|
131
|
-
//# sourceMappingURL=TableOfContentsPlugin.mjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,YAAY,EAAlB,SAAMA,YAAY,CAACC,KAAK,EAAEC,CAAC,EAAE,KAAoB;YAAlBC,OAAO,GAAT,KAAoB,CAAlBA,OAAO,EAAEC,OAAO,GAAlB,KAAoB,CAATA,OAAO;eAAI,wDAAA,mBAAA;gBAC3CC,SAAS,EACV,yBAAU,EAAV,iBAAU,EAAV,cAAU,EAAV,SAAU,EAAV,KAAU,EAAJC,IAAI,EACPC,OAAO,EA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