@jpmorganchase/mosaic-plugins 0.1.0-beta.5 → 0.1.0-beta.52
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 +39 -48
- package/dist/$AliasPlugin.js.map +1 -1
- package/dist/$CodeModPlugin.d.ts +7 -0
- package/dist/$CodeModPlugin.js +18 -30
- package/dist/$CodeModPlugin.js.map +1 -1
- package/dist/$RefPlugin.d.ts +31 -0
- package/dist/$RefPlugin.js +130 -127
- package/dist/$RefPlugin.js.map +1 -1
- package/dist/$TagPlugin.d.ts +28 -0
- package/dist/$TagPlugin.js +37 -56
- package/dist/$TagPlugin.js.map +1 -1
- package/dist/BreadcrumbsPlugin.d.ts +19 -0
- package/dist/BreadcrumbsPlugin.js +72 -32
- 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 +7 -0
- package/dist/FragmentPlugin.js +92 -0
- package/dist/FragmentPlugin.js.map +1 -0
- package/dist/LazyPagePlugin.d.ts +14 -0
- package/dist/LazyPagePlugin.js +55 -87
- package/dist/LazyPagePlugin.js.map +1 -1
- package/dist/PagesWithoutFileExtPlugin.d.ts +9 -0
- package/dist/PagesWithoutFileExtPlugin.js +19 -31
- 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 +23 -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 +134 -38
- package/dist/SharedConfigPlugin.js.map +1 -1
- package/dist/SidebarPlugin.d.ts +38 -0
- package/dist/SidebarPlugin.js +196 -95
- package/dist/SidebarPlugin.js.map +1 -1
- package/dist/SiteMapPlugin.d.ts +9 -0
- package/dist/SiteMapPlugin.js +20 -36
- package/dist/SiteMapPlugin.js.map +1 -1
- package/dist/TableOfContentsPlugin.d.ts +20 -0
- package/dist/TableOfContentsPlugin.js +43 -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/normaliseRefs.d.ts +1 -0
- package/dist/utils/normaliseRefs.js +52 -69
- package/dist/utils/normaliseRefs.js.map +1 -1
- package/package.json +46 -15
- package/CHANGELOG.md +0 -50
- 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/TableOfContentsPlugin.mjs +0 -140
- package/dist/TableOfContentsPlugin.mjs.map +0 -1
|
@@ -1,83 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const path_1 = __importDefault(require("path"));
|
|
16
|
-
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
17
|
-
const set_1 = __importDefault(require("lodash/set"));
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import glob from 'fast-glob';
|
|
3
|
+
import { set } from 'lodash-es';
|
|
18
4
|
function createFileGlob(url, pageExtensions) {
|
|
19
5
|
if (pageExtensions.length === 1) {
|
|
20
6
|
return `${url}${pageExtensions[0]}`;
|
|
21
7
|
}
|
|
22
8
|
return `${url}{${pageExtensions.join(',')}}`;
|
|
23
9
|
}
|
|
24
|
-
function normaliseRefs(filepath, refs, filesystem, pageExtensions, ignorePages) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
10
|
+
export default async function normaliseRefs(filepath, refs, filesystem, pageExtensions, ignorePages) {
|
|
11
|
+
const configWithoutGlobs = {};
|
|
12
|
+
for (let i = 0; i < refs.length; i++) {
|
|
13
|
+
const ref = refs[i];
|
|
14
|
+
const [url, fragment = ''] = ref.$$value.split('#');
|
|
15
|
+
if (!url) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
const fullUrl = path.posix.resolve(path.posix.dirname(filepath), url);
|
|
19
|
+
if (!glob.isDynamicPattern(url)) {
|
|
20
|
+
if (!(await filesystem.promises.exists(fullUrl))) {
|
|
21
|
+
throw new Error(`A \`$ref\` for '${filepath}' pointed to page '${fullUrl}' - which could not be found.`);
|
|
32
22
|
}
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (stat.isDirectory()) {
|
|
45
|
-
// && !/\/index(\.\w{1,4})?$/.test(url)) {
|
|
46
|
-
(0, set_1.default)(configWithoutGlobs, ref.$$path.slice(0, -1), {
|
|
47
|
-
$ref: `${yield filesystem.promises.realpath(path_1.default.join(refRealPath, 'index'))}#${fragment}`
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
(0, set_1.default)(configWithoutGlobs, ref.$$path.slice(0, -1), {
|
|
52
|
-
$ref: `${refRealPath}#${fragment}`
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
continue;
|
|
23
|
+
const refRealPath = await filesystem.promises.realpath(fullUrl
|
|
24
|
+
//path.resolve(path.dirname(filepath), url)
|
|
25
|
+
);
|
|
26
|
+
const stat = await filesystem.promises.stat(refRealPath);
|
|
27
|
+
// Turn directory refs into full index paths
|
|
28
|
+
// TODO: But DO we want to do this?
|
|
29
|
+
if (stat.isDirectory()) {
|
|
30
|
+
// && !/\/index(\.\w{1,4})?$/.test(url)) {
|
|
31
|
+
set(configWithoutGlobs, ref.$$path.slice(0, -1), {
|
|
32
|
+
$ref: `${await filesystem.promises.realpath(path.posix.join(refRealPath, 'index'))}#${fragment}`
|
|
33
|
+
});
|
|
56
34
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
yield filesystem.promises.glob(!/\/[^/]+\.\w{2,4}$/.test(url) ? createFileGlob(url, pageExtensions) : url, {
|
|
61
|
-
ignore: [filepath, ...ignorePages.map(ignore => `**/${ignore}`)],
|
|
62
|
-
cwd: path_1.default.dirname(filepath),
|
|
63
|
-
absolute: true
|
|
35
|
+
else {
|
|
36
|
+
set(configWithoutGlobs, ref.$$path.slice(0, -1), {
|
|
37
|
+
$ref: `${refRealPath}#${fragment}`
|
|
64
38
|
});
|
|
65
|
-
// Use a set so we de-dupe any symlinks that point to the same page
|
|
66
|
-
const resolvedRefs = new Set();
|
|
67
|
-
for (const value of globResolvedRefs) {
|
|
68
|
-
const refRealPath = yield filesystem.promises.realpath(path_1.default.resolve(filepath, value));
|
|
69
|
-
if (refRealPath !== (yield filesystem.promises.realpath(filepath))) {
|
|
70
|
-
resolvedRefs.add(`${refRealPath}#${fragment}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
(0, set_1.default)(configWithoutGlobs, ref.$$path.slice(0, -1), Array.from(resolvedRefs).map($ref => ({ $ref })));
|
|
74
39
|
}
|
|
75
|
-
|
|
76
|
-
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
let globResolvedRefs =
|
|
44
|
+
// If the pattern doesn't have an explicit file extension - then we'll make it just return pages
|
|
45
|
+
await filesystem.promises.glob(!/\/[^/]+\.\w{2,4}$/.test(url) ? createFileGlob(url, pageExtensions) : url, {
|
|
46
|
+
ignore: [filepath, ...ignorePages.map(ignore => `**/${ignore}`)],
|
|
47
|
+
cwd: path.dirname(filepath),
|
|
48
|
+
absolute: true
|
|
49
|
+
});
|
|
50
|
+
// Use a set so we de-dupe any symlinks that point to the same page
|
|
51
|
+
const resolvedRefs = new Set();
|
|
52
|
+
for (const value of globResolvedRefs) {
|
|
53
|
+
const refRealPath = await filesystem.promises.realpath(path.posix.resolve(filepath, value));
|
|
54
|
+
if (refRealPath !== (await filesystem.promises.realpath(filepath))) {
|
|
55
|
+
resolvedRefs.add(`${refRealPath}#${fragment}`);
|
|
56
|
+
}
|
|
77
57
|
}
|
|
58
|
+
set(configWithoutGlobs, ref.$$path.slice(0, -1), Array.from(resolvedRefs).map($ref => ({ $ref })));
|
|
78
59
|
}
|
|
79
|
-
|
|
80
|
-
|
|
60
|
+
catch (e) {
|
|
61
|
+
throw e;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return configWithoutGlobs;
|
|
81
65
|
}
|
|
82
|
-
exports.default = normaliseRefs;
|
|
83
66
|
//# sourceMappingURL=normaliseRefs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normaliseRefs.js","sourceRoot":"","sources":["../../src/utils/normaliseRefs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"normaliseRefs.js","sourceRoot":"","sources":["../../src/utils/normaliseRefs.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,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;AAED,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,aAAa,CACzC,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,cAAc,EACd,WAAW;IAEX,MAAM,kBAAkB,GAAG,EAAE,CAAC;IAE9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACpC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,MAAM,CAAC,GAAG,EAAE,QAAQ,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEpD,IAAI,CAAC,GAAG,EAAE;YACR,SAAS;SACV;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;QAEtE,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE;YAC/B,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,QAAQ,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,CAAC;gBAChE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;gBAC3B,QAAQ,EAAE,IAAI;aACf,CACF,CAAC;YAEJ,mEAAmE;YACnE,MAAM,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;YAE/B,KAAK,MAAM,KAAK,IAAI,gBAAgB,EAAE;gBACpC,MAAM,WAAW,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;gBAC5F,IAAI,WAAW,KAAK,CAAC,MAAM,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE;oBAClE,YAAY,CAAC,GAAG,CAAC,GAAG,WAAW,IAAI,QAAQ,EAAE,CAAC,CAAC;iBAChD;aACF;YAED,GAAG,CACD,kBAAkB,EAClB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EACvB,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CACjD,CAAC;SACH;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,CAAC;SACT;KACF;IAED,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,38 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jpmorganchase/mosaic-plugins",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.52",
|
|
4
4
|
"author": "",
|
|
5
5
|
"description": "Mosaic plugins for core file system",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
|
-
"
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./*": {
|
|
10
|
+
"types": "./dist/*.d.ts",
|
|
11
|
+
"import": "./dist/*.js",
|
|
12
|
+
"node": "./dist/*.js"
|
|
13
|
+
},
|
|
14
|
+
"./PluginError": {
|
|
15
|
+
"types": "./dist/utils/PluginError.d.ts",
|
|
16
|
+
"import": "./dist/utils/PluginError.js",
|
|
17
|
+
"node": "./dist/utils/PluginError.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
8
20
|
"engines": {
|
|
9
|
-
"node": ">=
|
|
21
|
+
"node": ">=16.10.0 || >=18.0.0"
|
|
10
22
|
},
|
|
11
23
|
"files": [
|
|
12
24
|
"dist"
|
|
13
25
|
],
|
|
14
26
|
"scripts": {
|
|
15
|
-
"build": "
|
|
16
|
-
"clean": "rm -fr dist"
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"clean": "rm -fr dist",
|
|
29
|
+
"lint": "eslint --ignore-pattern \"**/__tests__/**\""
|
|
17
30
|
},
|
|
18
31
|
"repository": {
|
|
19
32
|
"type": "git",
|
|
20
|
-
"url": "git@github.com:jpmorganchase/mosaic.git"
|
|
33
|
+
"url": "git@github.com:jpmorganchase/mosaic.git",
|
|
34
|
+
"directory": "packages/plugins"
|
|
21
35
|
},
|
|
22
36
|
"devDependencies": {
|
|
23
|
-
"@
|
|
24
|
-
"@swc/core": "^1.2.237",
|
|
25
|
-
"renamer": "^4.0.0"
|
|
37
|
+
"@types/fs-extra": "^9.0.13"
|
|
26
38
|
},
|
|
27
39
|
"dependencies": {
|
|
28
|
-
"@apidevtools/json-schema-ref-parser": "^
|
|
29
|
-
"@jpmorganchase/mosaic-
|
|
40
|
+
"@apidevtools/json-schema-ref-parser": "^10.1.0",
|
|
41
|
+
"@jpmorganchase/mosaic-schemas": "^0.1.0-beta.52",
|
|
42
|
+
"@jpmorganchase/mosaic-serialisers": "^0.1.0-beta.52",
|
|
43
|
+
"@jpmorganchase/mosaic-source-git-repo": "^0.1.0-beta.52",
|
|
44
|
+
"@jpmorganchase/mosaic-source-local-folder": "^0.1.0-beta.52",
|
|
45
|
+
"@jpmorganchase/mosaic-types": "^0.1.0-beta.52",
|
|
30
46
|
"@types/github-slugger": "^1.3.0",
|
|
47
|
+
"@vcarl/remark-headings": "^0.1.0",
|
|
48
|
+
"check-links": "^2.0.0",
|
|
49
|
+
"fs-extra": "^10.1.0",
|
|
31
50
|
"github-slugger": "^1.4.0",
|
|
32
|
-
"
|
|
33
|
-
"lodash": "^4.17.21",
|
|
34
|
-
"memfs": "^3.
|
|
51
|
+
"https-proxy-agent": "^5.0.1",
|
|
52
|
+
"lodash-es": "^4.17.21",
|
|
53
|
+
"memfs": "^3.4.12",
|
|
54
|
+
"react-docgen-typescript": "^2.2.2",
|
|
55
|
+
"react-pro-sidebar": "^1.0.0",
|
|
35
56
|
"reading-time": "^1.5.0",
|
|
36
|
-
"
|
|
57
|
+
"remark": "^14.0.2",
|
|
58
|
+
"remark-directive": "^2.0.1",
|
|
59
|
+
"remark-gfm": "^3.0.1",
|
|
60
|
+
"remark-mdx": "^2.1.5",
|
|
61
|
+
"remark-parse": "^10.0.1",
|
|
62
|
+
"remark-stringify": "^10.0.2",
|
|
63
|
+
"rxjs": "^7.5.5",
|
|
64
|
+
"unified": "^10.1.2",
|
|
65
|
+
"unist-util-visit": "^4.1.1",
|
|
66
|
+
"uuid": "^7.0.3",
|
|
67
|
+
"vfile-reporter": "^7.0.5"
|
|
37
68
|
}
|
|
38
69
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# @jpmorganchase/mosaic-plugins
|
|
2
|
-
|
|
3
|
-
## 0.1.0-beta.5
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- 61a246c: This releases add support for generate / build and serve snapshots
|
|
8
|
-
- Updated dependencies [61a246c]
|
|
9
|
-
- @jpmorganchase/mosaic-types@0.1.0-beta.5
|
|
10
|
-
|
|
11
|
-
## 0.1.0-beta.4
|
|
12
|
-
|
|
13
|
-
### Patch Changes
|
|
14
|
-
|
|
15
|
-
- bd285df: added dist to package.json
|
|
16
|
-
- Updated dependencies [bd285df]
|
|
17
|
-
- @jpmorganchase/mosaic-types@0.1.0-beta.4
|
|
18
|
-
|
|
19
|
-
## 0.1.0-beta.3
|
|
20
|
-
|
|
21
|
-
### Patch Changes
|
|
22
|
-
|
|
23
|
-
- 457df5e: switch to public package
|
|
24
|
-
- Updated dependencies [457df5e]
|
|
25
|
-
- @jpmorganchase/mosaic-types@0.1.0-beta.3
|
|
26
|
-
|
|
27
|
-
## 0.1.0-beta.2
|
|
28
|
-
|
|
29
|
-
### Patch Changes
|
|
30
|
-
|
|
31
|
-
- e1bbbe7: Initial release of Mosaic Core file-system.
|
|
32
|
-
|
|
33
|
-
Mosaic is a content aggregating service which pulls content from heterogeneous data sources.
|
|
34
|
-
|
|
35
|
-
- 4b2bc51: pipped to 0.1.0-beta.1 for publishing to NPM
|
|
36
|
-
- Updated dependencies [e1bbbe7]
|
|
37
|
-
- Updated dependencies [4b2bc51]
|
|
38
|
-
- @jpmorganchase/mosaic-types@0.1.0-beta.2
|
|
39
|
-
|
|
40
|
-
## 0.1.0
|
|
41
|
-
|
|
42
|
-
### Patch Changes
|
|
43
|
-
|
|
44
|
-
- e1bbbe7: Initial release of Mosaic Core file-system.
|
|
45
|
-
|
|
46
|
-
Mosaic is a content aggregating service which pulls content from heterogeneous data sources.
|
|
47
|
-
|
|
48
|
-
- Updated dependencies [e1bbbe7]
|
|
49
|
-
- Updated dependencies [bbc853c]
|
|
50
|
-
- @jpmorganchase/mosaic-types@0.1.0
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const lodash_1 = require("lodash");
|
|
13
|
-
/**
|
|
14
|
-
* Sorts the pages in a folder alphabetically and then embeds a `navigation` property to the metadata with ordered
|
|
15
|
-
* next/prev pages
|
|
16
|
-
*/
|
|
17
|
-
const NextPrevPlugin = {
|
|
18
|
-
$beforeSend(mutableFilesystem, { config, pageExtensions, ignorePages }, { indexFirst, sortBy }) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const pageDirs = (yield mutableFilesystem.promises.glob('**', {
|
|
21
|
-
onlyDirectories: true,
|
|
22
|
-
ignore: ignorePages.map(ignore => `**/${ignore}`),
|
|
23
|
-
cwd: '/'
|
|
24
|
-
}));
|
|
25
|
-
for (const dirName of pageDirs) {
|
|
26
|
-
const pages = (yield mutableFilesystem.promises.glob(createFileGlob('*', pageExtensions), {
|
|
27
|
-
onlyFiles: true,
|
|
28
|
-
cwd: dirName,
|
|
29
|
-
ignore: ignorePages
|
|
30
|
-
})).sort(createSortFn(pageExtensions, { indexFirst, sortBy }));
|
|
31
|
-
for (let i = 0; i < pages.length; i++) {
|
|
32
|
-
if (i > 0) {
|
|
33
|
-
config.setRef(pages[i], ['navigation', 'prev', 'title', '$ref'], `${pages[i - 1]}#/title`);
|
|
34
|
-
config.setRef(pages[i], ['navigation', 'prev', 'fullPath', '$ref'], `${pages[i - 1]}#/route`);
|
|
35
|
-
}
|
|
36
|
-
if (i < pages.length - 1) {
|
|
37
|
-
config.setRef(pages[i], ['navigation', 'next', 'title', '$ref'], `${pages[i + 1]}#/title`);
|
|
38
|
-
config.setRef(pages[i], ['navigation', 'next', 'fullPath', '$ref'], `${pages[i + 1]}#/route`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
exports.default = NextPrevPlugin;
|
|
46
|
-
function createFileGlob(url, pageExtensions) {
|
|
47
|
-
if (pageExtensions.length === 1) {
|
|
48
|
-
return `${url}${pageExtensions[0]}`;
|
|
49
|
-
}
|
|
50
|
-
return `${url}{${pageExtensions.join(',')}}`;
|
|
51
|
-
}
|
|
52
|
-
function createSortFn(pageExtensions, { sortBy: _sortBy, indexFirst }) {
|
|
53
|
-
const indexRegExp = indexFirst && new RegExp(`index${pageExtensions.map(lodash_1.escapeRegExp).join('|')}$`);
|
|
54
|
-
// TODO: Switch out the algorithm here, based on `sortBy`
|
|
55
|
-
return function sortFn(fullPathA, fullPathB) {
|
|
56
|
-
// Always pin /index to the front
|
|
57
|
-
if (indexFirst && indexRegExp.test(fullPathA)) {
|
|
58
|
-
return -1;
|
|
59
|
-
}
|
|
60
|
-
return fullPathA.localeCompare(fullPathB);
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=NextPrevPagePlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NextPrevPagePlugin.js","sourceRoot":"","sources":["../src/NextPrevPagePlugin.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,mCAAsC;AAEtC;;;GAGG;AACH,MAAM,cAAc,GAMhB;IACI,WAAW,CACf,iBAAiB,EACjB,EAAE,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,EACvC,EAAE,UAAU,EAAE,MAAM,EAAE;;YAEtB,MAAM,QAAQ,GAAG,CAAC,MAAM,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE;gBAC5D,eAAe,EAAE,IAAI;gBACrB,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,MAAM,EAAE,CAAC;gBACjD,GAAG,EAAE,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GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,CACzB,CAAC;qBACH;iBACF;aACF;QACH,CAAC;KAAA;CACF,CAAC;AAEF,kBAAe,cAAc,CAAC;AAE9B,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;AAED,SAAS,YAAY,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE;IACnE,MAAM,WAAW,GACf,UAAU,IAAI,IAAI,MAAM,CAAC,QAAQ,cAAc,CAAC,GAAG,CAAC,qBAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAElF,yDAAyD;IACzD,OAAO,SAAS,MAAM,CAAC,SAAS,EAAE,SAAS;QACzC,iCAAiC;QACjC,IAAI,UAAU,IAAI,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YAC7C,OAAO,CAAC,CAAC,CAAC;SACX;QACD,OAAO,SAAS,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,119 +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 getReadingTime from "reading-time";
|
|
32
|
-
import markdown from "remark-parse";
|
|
33
|
-
import { unified } from "unified";
|
|
34
|
-
import { visit } from "unist-util-visit";
|
|
35
|
-
/**
|
|
36
|
-
* Calculates reading time for pages and adds to frontmatter
|
|
37
|
-
*/ var ReadingTimePlugin = {
|
|
38
|
-
$afterSource: function $afterSource(pages) {
|
|
39
|
-
return _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() {
|
|
40
|
-
var processor, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, page, tree, textContent;
|
|
41
|
-
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
42
|
-
while(1)switch(_ctx.prev = _ctx.next){
|
|
43
|
-
case 0:
|
|
44
|
-
processor = unified().use(markdown);
|
|
45
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
46
|
-
_ctx.prev = 2;
|
|
47
|
-
_iterator = pages[Symbol.iterator]();
|
|
48
|
-
case 4:
|
|
49
|
-
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
|
|
50
|
-
_ctx.next = 15;
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
page = _step.value;
|
|
54
|
-
_ctx.next = 8;
|
|
55
|
-
return processor.parse(page.content);
|
|
56
|
-
case 8:
|
|
57
|
-
tree = _ctx.sent;
|
|
58
|
-
textContent = "";
|
|
59
|
-
visit(tree, function(node) {
|
|
60
|
-
return node.type === "text" || node.type === "code";
|
|
61
|
-
}, function(node) {
|
|
62
|
-
textContent += node.value;
|
|
63
|
-
});
|
|
64
|
-
page.readingTime = getReadingTime(textContent);
|
|
65
|
-
case 12:
|
|
66
|
-
_iteratorNormalCompletion = true;
|
|
67
|
-
_ctx.next = 4;
|
|
68
|
-
break;
|
|
69
|
-
case 15:
|
|
70
|
-
_ctx.next = 21;
|
|
71
|
-
break;
|
|
72
|
-
case 17:
|
|
73
|
-
_ctx.prev = 17;
|
|
74
|
-
_ctx.t0 = _ctx["catch"](2);
|
|
75
|
-
_didIteratorError = true;
|
|
76
|
-
_iteratorError = _ctx.t0;
|
|
77
|
-
case 21:
|
|
78
|
-
_ctx.prev = 21;
|
|
79
|
-
_ctx.prev = 22;
|
|
80
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
81
|
-
_iterator.return();
|
|
82
|
-
}
|
|
83
|
-
case 24:
|
|
84
|
-
_ctx.prev = 24;
|
|
85
|
-
if (!_didIteratorError) {
|
|
86
|
-
_ctx.next = 27;
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
throw _iteratorError;
|
|
90
|
-
case 27:
|
|
91
|
-
return _ctx.finish(24);
|
|
92
|
-
case 28:
|
|
93
|
-
return _ctx.finish(21);
|
|
94
|
-
case 29:
|
|
95
|
-
return _ctx.abrupt("return", pages);
|
|
96
|
-
case 30:
|
|
97
|
-
case "end":
|
|
98
|
-
return _ctx.stop();
|
|
99
|
-
}
|
|
100
|
-
}, _callee, null, [
|
|
101
|
-
[
|
|
102
|
-
2,
|
|
103
|
-
17,
|
|
104
|
-
21,
|
|
105
|
-
29
|
|
106
|
-
],
|
|
107
|
-
[
|
|
108
|
-
22,
|
|
109
|
-
,
|
|
110
|
-
24,
|
|
111
|
-
28
|
|
112
|
-
]
|
|
113
|
-
]);
|
|
114
|
-
}))();
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
export default ReadingTimePlugin;
|
|
118
|
-
|
|
119
|
-
//# sourceMappingURL=ReadingTimePlugin.mjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ReadingTimePlugin.mjs.ts"],"sourcesContent":["import type { Page, Plugin as PluginType } from '@jpmorganchase/mosaic-types';\nimport getReadingTime from 'reading-time';\nimport markdown from 'remark-parse';\nimport { unified } from 'unified';\nimport { visit } from 'unist-util-visit';\n\n/**\n * Calculates reading time for pages and adds to frontmatter\n */\nconst ReadingTimePlugin: PluginType<{}> = {\n async $afterSource(pages: Page[]) {\n const processor = unified().use(markdown);\n for (const page of pages) {\n const tree = await processor.parse(page.content);\n let textContent = '';\n\n visit(\n tree,\n node => node.type === 'text' || node.type === 'code',\n node => {\n textContent += node.value;\n }\n );\n page.readingTime = getReadingTime(textContent);\n }\n\n return pages;\n }\n};\n\nexport default ReadingTimePlugin;\n"],"names":["getReadingTime","markdown","unified","visit","ReadingTimePlugin","$afterSource","pages","processor","page","tree","textContent","use","parse","content","node","type","value","readingTime"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAOA,cAAc,MAAM,cAAc,CAAC;AAC1C,OAAOC,QAAQ,MAAM,cAAc,CAAC;AACpC,SAASC,OAAO,QAAQ,SAAS,CAAC;AAClC,SAASC,KAAK,QAAQ,kBAAkB,CAAC;AAEzC;;CAEC,GACD,IAAMC,iBAAiB,GAAmB;IAClCC,YAAY,EAAlB,SAAMA,YAAY,CAACC,KAAa;eAAE,wDAAA,mBAAA;gBAC1BC,SAAS,EACV,yBAAU,EAAV,iBAAU,EAAV,cAAU,EAAV,SAAU,EAAV,KAAU,EAAJC,IAAI,EACPC,IAAI,EACNC,WAAW;;;;wBAHXH,SAAS,GAAGL,OAAO,EAAE,CAACS,GAAG,CAACV,QAAQ,CAAC,CAAC;wBACrC,yBAAU,SAAV,iBAAU,UAAV,cAAU;;wBAAV,SAAU,GAAIK,KAAK;;4BAAnB,yBAAU,IAAV,KAAU,GAAV,SAAU;;;;wBAAJE,IAAI,GAAV,KAAU,MAAA;;+BACMD,SAAS,CAACK,KAAK,CAACJ,IAAI,CAACK,OAAO,CAAC;;wBAA1CJ,IAAI,YAAsC,CAAA;wBAC5CC,WAAW,GAAG,EAAE,CAAC;wBAErBP,KAAK,CACHM,IAAI,EACJK,SAAAA,IAAI;mCAAIA,IAAI,CAACC,IAAI,KAAK,MAAM,IAAID,IAAI,CAACC,IAAI,KAAK,MAAM;yBAAA,EACpDD,SAAAA,IAAI,EAAI;4BACNJ,WAAW,IAAII,IAAI,CAACE,KAAK,CAAC;yBAC3B,CACF,CAAC;wBACFR,IAAI,CAACS,WAAW,GAAGjB,cAAc,CAACU,WAAW,CAAC,CAAC;;wBAX5C,yBAAU;;;;;;;;;wBAAV,iBAAU;wBAAV,cAAU;;;;6BAAV,yBAAU,IAAV,SAAU;4BAAV,SAAU;;;;4BAAV,CAAA,iBAAU;;;;8BAAV,cAAU;;;;;;qDAcRJ,KAAK;;;;;;;;;;;;;;;;;;;SACb,EAAA;KAAA;CACF,AAAC;AAEF,eAAeF,iBAAiB,CAAC"}
|
|
@@ -1,140 +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
|
-
function _throw(e) {
|
|
31
|
-
throw e;
|
|
32
|
-
}
|
|
33
|
-
import regeneratorRuntime from "regenerator-runtime";
|
|
34
|
-
import Slugger from "github-slugger";
|
|
35
|
-
import { toString } from "hast-util-to-string";
|
|
36
|
-
import markdown from "remark-parse";
|
|
37
|
-
import { unified } from "unified";
|
|
38
|
-
import { visit } from "unist-util-visit";
|
|
39
|
-
/**
|
|
40
|
-
* Calculates table of contents from page headings
|
|
41
|
-
*/ var TableOfContentsPlugin = {
|
|
42
|
-
$afterSource: function $afterSource(pages, _$param, param) {
|
|
43
|
-
var _$param = _$param !== null ? _$param : _throw(new TypeError("Cannot destructure undefined")), minRank = param.minRank, maxRank = param.maxRank;
|
|
44
|
-
return _asyncToGenerator(/*#__PURE__*/ regeneratorRuntime.mark(function _callee() {
|
|
45
|
-
var processor, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, page, slugger, tree, items, test, isHeadingInRange;
|
|
46
|
-
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
47
|
-
while(1)switch(_ctx.prev = _ctx.next){
|
|
48
|
-
case 0:
|
|
49
|
-
test = function _test(node) {
|
|
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);
|
|
60
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
61
|
-
_ctx.prev = 4;
|
|
62
|
-
_iterator = pages[Symbol.iterator]();
|
|
63
|
-
case 6:
|
|
64
|
-
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
|
|
65
|
-
_ctx.next = 18;
|
|
66
|
-
break;
|
|
67
|
-
}
|
|
68
|
-
page = _step.value;
|
|
69
|
-
slugger = new Slugger();
|
|
70
|
-
_ctx.next = 11;
|
|
71
|
-
return processor.parse(page.content);
|
|
72
|
-
case 11:
|
|
73
|
-
tree = _ctx.sent;
|
|
74
|
-
items = [];
|
|
75
|
-
visit(tree, function(node) {
|
|
76
|
-
return test(node);
|
|
77
|
-
}, function(node) {
|
|
78
|
-
var text = toString(node).trim();
|
|
79
|
-
items.push({
|
|
80
|
-
level: node.depth,
|
|
81
|
-
id: slugger.slug(text),
|
|
82
|
-
text: text
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
page.tableOfContents = items;
|
|
86
|
-
case 15:
|
|
87
|
-
_iteratorNormalCompletion = true;
|
|
88
|
-
_ctx.next = 6;
|
|
89
|
-
break;
|
|
90
|
-
case 18:
|
|
91
|
-
_ctx.next = 24;
|
|
92
|
-
break;
|
|
93
|
-
case 20:
|
|
94
|
-
_ctx.prev = 20;
|
|
95
|
-
_ctx.t0 = _ctx["catch"](4);
|
|
96
|
-
_didIteratorError = true;
|
|
97
|
-
_iteratorError = _ctx.t0;
|
|
98
|
-
case 24:
|
|
99
|
-
_ctx.prev = 24;
|
|
100
|
-
_ctx.prev = 25;
|
|
101
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
102
|
-
_iterator.return();
|
|
103
|
-
}
|
|
104
|
-
case 27:
|
|
105
|
-
_ctx.prev = 27;
|
|
106
|
-
if (!_didIteratorError) {
|
|
107
|
-
_ctx.next = 30;
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
throw _iteratorError;
|
|
111
|
-
case 30:
|
|
112
|
-
return _ctx.finish(27);
|
|
113
|
-
case 31:
|
|
114
|
-
return _ctx.finish(24);
|
|
115
|
-
case 32:
|
|
116
|
-
return _ctx.abrupt("return", pages);
|
|
117
|
-
case 35:
|
|
118
|
-
case "end":
|
|
119
|
-
return _ctx.stop();
|
|
120
|
-
}
|
|
121
|
-
}, _callee, null, [
|
|
122
|
-
[
|
|
123
|
-
4,
|
|
124
|
-
20,
|
|
125
|
-
24,
|
|
126
|
-
32
|
|
127
|
-
],
|
|
128
|
-
[
|
|
129
|
-
25,
|
|
130
|
-
,
|
|
131
|
-
27,
|
|
132
|
-
31
|
|
133
|
-
]
|
|
134
|
-
]);
|
|
135
|
-
}))();
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
export default TableOfContentsPlugin;
|
|
139
|
-
|
|
140
|
-
//# 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 { toString } from 'hast-util-to-string';\nimport markdown from 'remark-parse';\nimport { unified } from 'unified';\nimport { visit } from 'unist-util-visit';\n\ntype TOCItem = { level: number; id: string; text: string };\n\n/**\n * Calculates table of contents from page headings\n */\nconst TableOfContentsPlugin: PluginType<{}, { minRank: 2; maxRank: 4 }> = {\n async $afterSource(pages: Page[], {}, { minRank, maxRank }) {\n const processor = unified().use(markdown);\n for (const page of pages) {\n const slugger = new Slugger();\n const tree = await processor.parse(page.content);\n const items: TOCItem[] = [];\n visit(\n tree,\n node => test(node),\n node => {\n const text = toString(node).trim();\n items.push({\n level: node.depth,\n id: slugger.slug(text),\n text: text\n });\n }\n );\n page.tableOfContents = items;\n }\n\n return pages;\n\n function test(node) {\n return node.type === 'heading' && isHeadingInRange(node);\n }\n\n function isHeadingInRange(node) {\n const depth = node.depth;\n if (depth < minRank || depth > maxRank) {\n return false;\n }\n return true;\n }\n }\n};\n\nexport default TableOfContentsPlugin;\n"],"names":["Slugger","toString","markdown","unified","visit","TableOfContentsPlugin","$afterSource","pages","minRank","maxRank","processor","page","slugger","tree","items","test","isHeadingInRange","node","type","depth","use","parse","content","text","trim","push","level","id","slug","tableOfContents"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAOA,OAAO,MAAM,gBAAgB,CAAC;AACrC,SAASC,QAAQ,QAAQ,qBAAqB,CAAC;AAC/C,OAAOC,QAAQ,MAAM,cAAc,CAAC;AACpC,SAASC,OAAO,QAAQ,SAAS,CAAC;AAClC,SAASC,KAAK,QAAQ,kBAAkB,CAAC;AAIzC;;CAEC,GACD,IAAMC,qBAAqB,GAA+C;IAClEC,YAAY,EAAlB,SAAMA,YAAY,CAACC,KAAa,EAAE,OAAE,EAAE,KAAoB;YAAxB,OAAE,GAAF,OAAE,YAAF,OAAE,wDAAA,EAAIC,OAAO,GAAT,KAAoB,CAAlBA,OAAO,EAAEC,OAAO,GAAlB,KAAoB,CAATA,OAAO;eAAI,wDAAA,mBAAA;gBACpDC,SAAS,EACV,yBAAU,EAAV,iBAAU,EAAV,cAAU,EAAV,SAAU,EAAV,KAAU,EAAJC,IAAI,EACPC,OAAO,EACPC,IAAI,EACJC,KAAK,EAkBJC,IAAI,EAIJC,gBAAgB;;;;wBAJzB,AAASD,IAAI,GAAb,SAASA,KAAI,CAACE,IAAI,EAAE;4BAClB,OAAOA,IAAI,CAACC,IAAI,KAAK,SAAS,IAAIF,gBAAgB,CAACC,IAAI,CAAC,CAAC;yBAC1D;wBAED,AAASD,gBAAgB,GAAzB,SAASA,iBAAgB,CAACC,IAAI,EAAE;4BAC9B,IAAME,KAAK,GAAGF,IAAI,CAACE,KAAK,AAAC;4BACzB,IAAIA,KAAK,GAAGX,OAAO,IAAIW,KAAK,GAAGV,OAAO,EAAE;gCACtC,OAAO,KAAK,CAAC;6BACd;4B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