@docusaurus/utils 2.4.1 → 3.0.0-beta.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/lib/constants.d.ts +1 -1
- package/lib/constants.d.ts.map +1 -1
- package/lib/contentVisibilityUtils.d.ts +29 -0
- package/lib/contentVisibilityUtils.d.ts.map +1 -0
- package/lib/contentVisibilityUtils.js +39 -0
- package/lib/contentVisibilityUtils.js.map +1 -0
- package/lib/dataFileUtils.d.ts +1 -1
- package/lib/dataFileUtils.d.ts.map +1 -1
- package/lib/globUtils.d.ts +1 -1
- package/lib/globUtils.d.ts.map +1 -1
- package/lib/globUtils.js +2 -1
- package/lib/globUtils.js.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -2
- package/lib/index.js.map +1 -1
- package/lib/jsUtils.d.ts +4 -0
- package/lib/jsUtils.d.ts.map +1 -1
- package/lib/jsUtils.js +11 -1
- package/lib/jsUtils.js.map +1 -1
- package/lib/markdownLinks.d.ts +2 -2
- package/lib/markdownLinks.d.ts.map +1 -1
- package/lib/markdownLinks.js +38 -18
- package/lib/markdownLinks.js.map +1 -1
- package/lib/markdownUtils.d.ts +27 -2
- package/lib/markdownUtils.d.ts.map +1 -1
- package/lib/markdownUtils.js +57 -2
- package/lib/markdownUtils.js.map +1 -1
- package/lib/pathUtils.d.ts +6 -2
- package/lib/pathUtils.d.ts.map +1 -1
- package/lib/pathUtils.js +7 -3
- package/lib/pathUtils.js.map +1 -1
- package/lib/slugger.d.ts +2 -2
- package/lib/slugger.d.ts.map +1 -1
- package/lib/tags.d.ts +19 -5
- package/lib/tags.d.ts.map +1 -1
- package/lib/tags.js +21 -1
- package/lib/tags.js.map +1 -1
- package/lib/urlUtils.js +2 -2
- package/lib/urlUtils.js.map +1 -1
- package/lib/webpackUtils.d.ts +2 -2
- package/lib/webpackUtils.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/contentVisibilityUtils.ts +54 -0
- package/src/globUtils.ts +4 -1
- package/src/index.ts +5 -0
- package/src/jsUtils.ts +10 -0
- package/src/markdownLinks.ts +56 -22
- package/src/markdownUtils.ts +70 -1
- package/src/pathUtils.ts +7 -3
- package/src/tags.ts +31 -0
- package/src/urlUtils.ts +3 -3
package/lib/pathUtils.d.ts
CHANGED
|
@@ -40,12 +40,16 @@ export declare function aliasedSitePath(filePath: string, siteDir: string): stri
|
|
|
40
40
|
* When you have a path like C:\X\Y
|
|
41
41
|
* It is not safe to use directly when generating code
|
|
42
42
|
* For example, this would fail due to unescaped \:
|
|
43
|
-
* `<img src={require(
|
|
44
|
-
* But this would work: `<img src={require(
|
|
43
|
+
* `<img src={require("${filePath}")} />`
|
|
44
|
+
* But this would work: `<img src={require("${escapePath(filePath)}")} />`
|
|
45
45
|
*
|
|
46
46
|
* posixPath can't be used in all cases, because forward slashes are only valid
|
|
47
47
|
* Windows paths when they don't contain non-ascii characters, and posixPath
|
|
48
48
|
* doesn't escape those that fail to be converted.
|
|
49
|
+
*
|
|
50
|
+
* This function escapes double quotes but not single quotes (because it uses
|
|
51
|
+
* `JSON.stringify`). Therefore, you must put the escaped path inside double
|
|
52
|
+
* quotes when generating code.
|
|
49
53
|
*/
|
|
50
54
|
export declare function escapePath(str: string): string;
|
|
51
55
|
export declare function addTrailingPathSeparator(str: string): string;
|
package/lib/pathUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../src/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,eAAO,MAAM,aAAa,QAAS,MAAM,KAAG,OAMgC,CAAC;AAE7E,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAiB7C;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO7C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKzE;AAED
|
|
1
|
+
{"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../src/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,eAAO,MAAM,aAAa,QAAS,MAAM,KAAG,OAMgC,CAAC;AAE7E,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAiB7C;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO7C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKzE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK9C;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK5D"}
|
package/lib/pathUtils.js
CHANGED
|
@@ -88,12 +88,16 @@ exports.aliasedSitePath = aliasedSitePath;
|
|
|
88
88
|
* When you have a path like C:\X\Y
|
|
89
89
|
* It is not safe to use directly when generating code
|
|
90
90
|
* For example, this would fail due to unescaped \:
|
|
91
|
-
* `<img src={require(
|
|
92
|
-
* But this would work: `<img src={require(
|
|
91
|
+
* `<img src={require("${filePath}")} />`
|
|
92
|
+
* But this would work: `<img src={require("${escapePath(filePath)}")} />`
|
|
93
93
|
*
|
|
94
94
|
* posixPath can't be used in all cases, because forward slashes are only valid
|
|
95
95
|
* Windows paths when they don't contain non-ascii characters, and posixPath
|
|
96
96
|
* doesn't escape those that fail to be converted.
|
|
97
|
+
*
|
|
98
|
+
* This function escapes double quotes but not single quotes (because it uses
|
|
99
|
+
* `JSON.stringify`). Therefore, you must put the escaped path inside double
|
|
100
|
+
* quotes when generating code.
|
|
97
101
|
*/
|
|
98
102
|
function escapePath(str) {
|
|
99
103
|
const escaped = JSON.stringify(str);
|
|
@@ -105,7 +109,7 @@ function addTrailingPathSeparator(str) {
|
|
|
105
109
|
return str.endsWith(path_1.default.sep)
|
|
106
110
|
? str
|
|
107
111
|
: // If this is Windows, we need to change the forward slash to backward
|
|
108
|
-
`${str.replace(
|
|
112
|
+
`${str.replace(/[\\/]$/, '')}${path_1.default.sep}`;
|
|
109
113
|
}
|
|
110
114
|
exports.addTrailingPathSeparator = addTrailingPathSeparator;
|
|
111
115
|
//# sourceMappingURL=pathUtils.js.map
|
package/lib/pathUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathUtils.js","sourceRoot":"","sources":["../src/pathUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,wDAAwB;AAExB,+DAA+D;AAC/D,qEAAqE;AACrE,qBAAqB;AACrB,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,0EAA0E;AAC1E,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC;AACpD,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;AAE9C,MAAM,aAAa,GAAG,CAAC,GAAW,EAAW,EAAE;AACpD,qEAAqE;AACrE,OAAO,EAAE,IAAI,SAAS,EAAE;IACtB,CAAC,CAAC,oEAAoE;QACpE,GAAG,CAAC,MAAM,GAAG,mBAAmB,GAAG,sBAAsB;IAC3D,CAAC,CAAC,oBAAoB;QACpB,MAAM,CAAC,IA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C,CAAC;AAClD,CAAC;AALD,gCAKC;AAED,SAAgB,wBAAwB,CAAC,GAAW;IAClD,OAAO,GAAG,CAAC,QAAQ,CAAC,cAAI,CAAC,GAAG,CAAC;QAC3B,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,sEAAsE;YACtE,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,cAAI,CAAC,GAAG,EAAE,CAAC;AAChD,CAAC;AALD,4DAKC"}
|
package/lib/slugger.d.ts
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export type SluggerOptions = {
|
|
8
8
|
/** Keep the headings' casing, otherwise make all lowercase. */
|
|
9
9
|
maintainCase?: boolean;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type Slugger = {
|
|
12
12
|
/**
|
|
13
13
|
* Takes a Markdown heading like "Josh Cena" and sluggifies it according to
|
|
14
14
|
* GitHub semantics (in this case `josh-cena`). Stateful, because if you try
|
package/lib/slugger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slugger.d.ts","sourceRoot":"","sources":["../src/slugger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,
|
|
1
|
+
{"version":3,"file":"slugger.d.ts","sourceRoot":"","sources":["../src/slugger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,MAAM,MAAM,cAAc,GAAG;IAC3B,+DAA+D;IAC/D,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB;;;;OAIG;IACH,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,KAAK,MAAM,CAAC;CAC3D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAKvC"}
|
package/lib/tags.d.ts
CHANGED
|
@@ -5,22 +5,24 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
/** What the user configures. */
|
|
8
|
-
export
|
|
8
|
+
export type Tag = {
|
|
9
9
|
label: string;
|
|
10
10
|
/** Permalink to this tag's page, without the `/tags/` base path. */
|
|
11
11
|
permalink: string;
|
|
12
12
|
};
|
|
13
13
|
/** What the tags list page should know about each tag. */
|
|
14
|
-
export
|
|
14
|
+
export type TagsListItem = Tag & {
|
|
15
15
|
/** Number of posts/docs with this tag. */
|
|
16
16
|
count: number;
|
|
17
17
|
};
|
|
18
18
|
/** What the tag's own page should know about the tag. */
|
|
19
|
-
export
|
|
19
|
+
export type TagModule = TagsListItem & {
|
|
20
20
|
/** The tags list page's permalink. */
|
|
21
21
|
allTagsPath: string;
|
|
22
|
+
/** Is this tag unlisted? (when it only contains unlisted items) */
|
|
23
|
+
unlisted: boolean;
|
|
22
24
|
};
|
|
23
|
-
export
|
|
25
|
+
export type FrontMatterTag = string | Tag;
|
|
24
26
|
/**
|
|
25
27
|
* Takes tag objects as they are defined in front matter, and normalizes each
|
|
26
28
|
* into a standard tag object. The permalink is created by appending the
|
|
@@ -35,7 +37,7 @@ export declare function normalizeFrontMatterTags(
|
|
|
35
37
|
tagsPath: string,
|
|
36
38
|
/** Can be `undefined`, so that we can directly pipe in `frontMatter.tags`. */
|
|
37
39
|
frontMatterTags?: FrontMatterTag[] | undefined): Tag[];
|
|
38
|
-
|
|
40
|
+
type TaggedItemGroup<Item> = {
|
|
39
41
|
tag: Tag;
|
|
40
42
|
items: Item[];
|
|
41
43
|
};
|
|
@@ -55,5 +57,17 @@ export declare function groupTaggedItems<Item>(items: readonly Item[],
|
|
|
55
57
|
getItemTags: (item: Item) => readonly Tag[]): {
|
|
56
58
|
[permalink: string]: TaggedItemGroup<Item>;
|
|
57
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Permits to get the "tag visibility" (hard to find a better name)
|
|
62
|
+
* IE, is this tag listed or unlisted
|
|
63
|
+
* And which items should be listed when this tag is browsed
|
|
64
|
+
*/
|
|
65
|
+
export declare function getTagVisibility<Item>({ items, isUnlisted, }: {
|
|
66
|
+
items: Item[];
|
|
67
|
+
isUnlisted: (item: Item) => boolean;
|
|
68
|
+
}): {
|
|
69
|
+
unlisted: boolean;
|
|
70
|
+
listedItems: Item[];
|
|
71
|
+
};
|
|
58
72
|
export {};
|
|
59
73
|
//# sourceMappingURL=tags.d.ts.map
|
package/lib/tags.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,gCAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,gCAAgC;AAChC,MAAM,MAAM,GAAG,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,0DAA0D;AAC1D,MAAM,MAAM,YAAY,GAAG,GAAG,GAAG;IAC/B,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,yDAAyD;AACzD,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG;IACrC,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,GAAG,CAAC;AAgC1C;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB;AACtC,iDAAiD;AACjD,QAAQ,EAAE,MAAM;AAChB,8EAA8E;AAC9E,eAAe,GAAE,cAAc,EAAE,GAAG,SAAc,GACjD,GAAG,EAAE,CAMP;AAED,KAAK,eAAe,CAAC,IAAI,IAAI;IAC3B,GAAG,EAAE,GAAG,CAAC;IACT,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EACnC,KAAK,EAAE,SAAS,IAAI,EAAE;AACtB;;;GAGG;AACH,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,SAAS,GAAG,EAAE,GAC1C;IAAC,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;CAAC,CA0B9C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,EACrC,KAAK,EACL,UAAU,GACX,EAAE;IACD,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;CACrC,GAAG;IACF,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,IAAI,EAAE,CAAC;CACrB,CAaA"}
|
package/lib/tags.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.groupTaggedItems = exports.normalizeFrontMatterTags = void 0;
|
|
9
|
+
exports.getTagVisibility = exports.groupTaggedItems = exports.normalizeFrontMatterTags = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
12
|
const urlUtils_1 = require("./urlUtils");
|
|
@@ -88,4 +88,24 @@ getItemTags) {
|
|
|
88
88
|
return result;
|
|
89
89
|
}
|
|
90
90
|
exports.groupTaggedItems = groupTaggedItems;
|
|
91
|
+
/**
|
|
92
|
+
* Permits to get the "tag visibility" (hard to find a better name)
|
|
93
|
+
* IE, is this tag listed or unlisted
|
|
94
|
+
* And which items should be listed when this tag is browsed
|
|
95
|
+
*/
|
|
96
|
+
function getTagVisibility({ items, isUnlisted, }) {
|
|
97
|
+
const allItemsUnlisted = items.every(isUnlisted);
|
|
98
|
+
// When a tag is full of unlisted items, we display all the items
|
|
99
|
+
// when tag is browsed, but we mark the tag as unlisted
|
|
100
|
+
if (allItemsUnlisted) {
|
|
101
|
+
return { unlisted: true, listedItems: items };
|
|
102
|
+
}
|
|
103
|
+
// When a tag has some listed items, the tag remains listed
|
|
104
|
+
// but we filter its unlisted items
|
|
105
|
+
return {
|
|
106
|
+
unlisted: false,
|
|
107
|
+
listedItems: items.filter((item) => !isUnlisted(item)),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
exports.getTagVisibility = getTagVisibility;
|
|
91
111
|
//# sourceMappingURL=tags.js.map
|
package/lib/tags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,4DAAuB;AACvB,yCAAwC;
|
|
1
|
+
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,4DAAuB;AACvB,yCAAwC;AAyBxC,SAAS,uBAAuB,CAC9B,QAAgB,EAChB,cAA8B;IAE9B,SAAS,WAAW,CAAC,SAAiB;QACpC,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,SAAS,EAAE,gBAAC,CAAC,SAAS,CAAC,SAAS,CAAC;SAClC,CAAC;IACJ,CAAC;IAED,0DAA0D;IAC1D,SAAS,qBAAqB,CAAC,SAAiB;QAC9C,2EAA2E;QAC3E,2EAA2E;QAC3E,mDAAmD;QACnD,OAAO,IAAA,uBAAY,EAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,GAAG,GACP,OAAO,cAAc,KAAK,QAAQ;QAChC,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC;QAC7B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C,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAjCD,4CAiCC;AAED;;;;GAIG;AACH,SAAgB,gBAAgB,CAAO,EACrC,KAAK,EACL,UAAU,GAIX;IAIC,MAAM,gBAAgB,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACjD,iEAAiE;IACjE,uDAAuD;IACvD,IAAI,gBAAgB,EAAE;QACpB,OAAO,EAAC,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAC,CAAC;KAC7C;IACD,2DAA2D;IAC3D,mCAAmC;IACnC,OAAO;QACL,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;KACvD,CAAC;AACJ,CAAC;AAtBD,4CAsBC"}
|
package/lib/urlUtils.js
CHANGED
|
@@ -156,13 +156,13 @@ function resolvePathname(to, from) {
|
|
|
156
156
|
exports.resolvePathname = resolvePathname;
|
|
157
157
|
/** Appends a leading slash to `str`, if one doesn't exist. */
|
|
158
158
|
function addLeadingSlash(str) {
|
|
159
|
-
return
|
|
159
|
+
return (0, jsUtils_1.addPrefix)(str, '/');
|
|
160
160
|
}
|
|
161
161
|
exports.addLeadingSlash = addLeadingSlash;
|
|
162
162
|
// TODO deduplicate: also present in @docusaurus/utils-common
|
|
163
163
|
/** Appends a trailing slash to `str`, if one doesn't exist. */
|
|
164
164
|
function addTrailingSlash(str) {
|
|
165
|
-
return
|
|
165
|
+
return (0, jsUtils_1.addSuffix)(str, '/');
|
|
166
166
|
}
|
|
167
167
|
exports.addTrailingSlash = addTrailingSlash;
|
|
168
168
|
/** Removes the trailing slash from `str`. */
|
package/lib/urlUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlUtils.js","sourceRoot":"","sources":["../src/urlUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,gFAAqD;AACrD,
|
|
1
|
+
{"version":3,"file":"urlUtils.js","sourceRoot":"","sources":["../src/urlUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,gFAAqD;AACrD,uCAA6D;AAE7D;;;;;;;;;;;GAWG;AACH,SAAgB,YAAY,CAAC,OAAiB;IAC5C,MAAM,IAAI,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC;IAC1B,MAAM,WAAW,GAAG,EAAE,CAAC;IAEvB,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAC7B,IAAI,cAAc,GAAG,KAAK,CAAC;IAE3B,MAAM,eAAe,GAAG,CAAC,GAAa,EAAgC,EAAE,CACtE,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;IAEjB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;QAC1B,OAAO,EAAE,CAAC;KACX;IAED,2EAA2E;IAC3E,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAG,CAAC;QAC5B,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YACxD,wEAAwE;YACxE,8BAA8B;YAC9B,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;SAClC;aAAM;YACL,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;SAC3B;KACF;IAED,2DAA2D;IAC3D,gCAAgC;IAChC,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,C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C,OAAO,IAAA,sBAAY,EAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC;AAFD,kDAEC;AAED,gEAAgE;AAChE,SAAgB,WAAW,CACzB,UAAkB,EAClB,gBAAwB,EACxB,WAAmB,EACnB,UAAmB;IAEnB,IAAI,UAAU,EAAE;QACd,OAAO,aAAa,UAAU,IAAI,UAAU,IAAI,gBAAgB,IAAI,WAAW,MAAM,CAAC;KACvF;IACD,OAAO,OAAO,UAAU,IAAI,gBAAgB,IAAI,WAAW,MAAM,CAAC;AACpE,CAAC;AAVD,kCAUC;AAED,iEAAiE;AACjE,SAAgB,aAAa,CAC3B,cAAsB,EACtB,UAAkB,EAClB,gBAAwB,EACxB,WAAmB,EACnB,UAAmB;IAEnB,IAAI,UAAU,EAAE;QACd,OAAO,WAAW,cAAc,IAAI,UAAU,IAAI,UAAU,IAAI,gBAAgB,IAAI,WAAW,MAAM,CAAC;KACvG;IACD,OAAO,WAAW,cAAc,IAAI,UAAU,IAAI,gBAAgB,IAAI,WAAW,MAAM,CAAC;AAC1F,CAAC;AAXD,sCAWC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAC,aAAqB;IAClD,IAAI;QACF,IAAI,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC,QAAQ,KAAK,MAAM,EAAE;YAC9C,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;KACd;IAAC,MAAM;QACN,oCAAoC;QACpC,OAAO,+BAA+B,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;KAC5D;AACH,CAAC;AAVD,wCAUC"}
|
package/lib/webpackUtils.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { RuleSetRule } from 'webpack';
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
type AssetFolder = 'images' | 'files' | 'fonts' | 'medias';
|
|
9
|
+
type FileLoaderUtils = {
|
|
10
10
|
loaders: {
|
|
11
11
|
file: (options: {
|
|
12
12
|
folder: AssetFolder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpackUtils.d.ts","sourceRoot":"","sources":["../src/webpackUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAEzC,
|
|
1
|
+
{"version":3,"file":"webpackUtils.d.ts","sourceRoot":"","sources":["../src/webpackUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAEzC,KAAK,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE3D,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE;QACP,IAAI,EAAE,CAAC,OAAO,EAAE;YAAC,MAAM,EAAE,WAAW,CAAA;SAAC,KAAK,WAAW,CAAC;QACtD,GAAG,EAAE,CAAC,OAAO,EAAE;YAAC,MAAM,EAAE,WAAW,CAAA;SAAC,KAAK,WAAW,CAAC;QACrD,6BAA6B,EAAE,MAAM,CAAC;QACtC,4BAA4B,EAAE,MAAM,CAAC;KACtC,CAAC;IACF,KAAK,EAAE;QACL,MAAM,EAAE,MAAM,WAAW,CAAC;QAC1B,KAAK,EAAE,MAAM,WAAW,CAAC;QACzB,KAAK,EAAE,MAAM,WAAW,CAAC;QACzB,GAAG,EAAE,MAAM,WAAW,CAAC;QACvB,WAAW,EAAE,MAAM,WAAW,CAAC;KAChC,CAAC;CACH,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CAkHpD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.0",
|
|
4
4
|
"description": "Node utility functions for Docusaurus packages.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/logger": "
|
|
22
|
-
"@svgr/webpack": "^6.
|
|
21
|
+
"@docusaurus/logger": "3.0.0-beta.0",
|
|
22
|
+
"@svgr/webpack": "^6.5.1",
|
|
23
23
|
"escape-string-regexp": "^4.0.0",
|
|
24
24
|
"file-loader": "^6.2.0",
|
|
25
|
-
"fs-extra": "^
|
|
26
|
-
"github-slugger": "^1.
|
|
25
|
+
"fs-extra": "^11.1.1",
|
|
26
|
+
"github-slugger": "^1.5.0",
|
|
27
27
|
"globby": "^11.1.0",
|
|
28
28
|
"gray-matter": "^4.0.3",
|
|
29
29
|
"js-yaml": "^4.1.0",
|
|
@@ -31,19 +31,19 @@
|
|
|
31
31
|
"micromatch": "^4.0.5",
|
|
32
32
|
"resolve-pathname": "^3.0.0",
|
|
33
33
|
"shelljs": "^0.8.5",
|
|
34
|
-
"tslib": "^2.
|
|
34
|
+
"tslib": "^2.6.0",
|
|
35
35
|
"url-loader": "^4.1.1",
|
|
36
|
-
"webpack": "^5.
|
|
36
|
+
"webpack": "^5.88.1"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=16.14"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@docusaurus/types": "
|
|
42
|
+
"@docusaurus/types": "3.0.0-beta.0",
|
|
43
43
|
"@types/dedent": "^0.7.0",
|
|
44
44
|
"@types/github-slugger": "^1.3.0",
|
|
45
45
|
"@types/micromatch": "^4.0.2",
|
|
46
|
-
"@types/react-dom": "^18.
|
|
46
|
+
"@types/react-dom": "^18.2.7",
|
|
47
47
|
"dedent": "^0.7.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"optional": true
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "27a1e90d9fff88af90ecad35bea16d4d7230482a"
|
|
58
58
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
type Env = 'production' | 'development';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* To easily work on draft/unlisted in dev mode, use this env variable!
|
|
12
|
+
* SIMULATE_PRODUCTION_VISIBILITY=true yarn start:website
|
|
13
|
+
*/
|
|
14
|
+
const simulateProductionVisibility =
|
|
15
|
+
process.env.SIMULATE_PRODUCTION_VISIBILITY === 'true';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* draft/unlisted is a production-only concept
|
|
19
|
+
* In dev it is ignored and all content files are included
|
|
20
|
+
*/
|
|
21
|
+
function isProduction(env: Env | undefined): boolean {
|
|
22
|
+
return (
|
|
23
|
+
simulateProductionVisibility ||
|
|
24
|
+
(env ?? process.env.NODE_ENV) === 'production'
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A draft content will not be included in the production build
|
|
30
|
+
*/
|
|
31
|
+
export function isDraft({
|
|
32
|
+
frontMatter,
|
|
33
|
+
env,
|
|
34
|
+
}: {
|
|
35
|
+
frontMatter: {draft?: boolean};
|
|
36
|
+
env?: Env;
|
|
37
|
+
}): boolean {
|
|
38
|
+
return (isProduction(env) && frontMatter.draft) ?? false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* An unlisted content will be included in the production build, but hidden.
|
|
43
|
+
* It is excluded from sitemap, has noIndex, does not appear in lists etc...
|
|
44
|
+
* Only users having the link can find it.
|
|
45
|
+
*/
|
|
46
|
+
export function isUnlisted({
|
|
47
|
+
frontMatter,
|
|
48
|
+
env,
|
|
49
|
+
}: {
|
|
50
|
+
frontMatter: {unlisted?: boolean};
|
|
51
|
+
env?: Env;
|
|
52
|
+
}): boolean {
|
|
53
|
+
return (isProduction(env) && frontMatter.unlisted) ?? false;
|
|
54
|
+
}
|
package/src/globUtils.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import path from 'path';
|
|
11
11
|
import Micromatch from 'micromatch'; // Note: Micromatch is used by Globby
|
|
12
|
+
import {addSuffix} from './jsUtils';
|
|
12
13
|
|
|
13
14
|
/** A re-export of the globby instance. */
|
|
14
15
|
export {default as Globby} from 'globby';
|
|
@@ -68,7 +69,9 @@ export function createAbsoluteFilePathMatcher(
|
|
|
68
69
|
|
|
69
70
|
function getRelativeFilePath(absoluteFilePath: string) {
|
|
70
71
|
const rootFolder = rootFolders.find((folderPath) =>
|
|
71
|
-
|
|
72
|
+
[addSuffix(folderPath, '/'), addSuffix(folderPath, '\\')].some((p) =>
|
|
73
|
+
absoluteFilePath.startsWith(p),
|
|
74
|
+
),
|
|
72
75
|
);
|
|
73
76
|
if (!rootFolder) {
|
|
74
77
|
throw new Error(
|
package/src/index.ts
CHANGED
|
@@ -62,9 +62,13 @@ export {
|
|
|
62
62
|
type FrontMatterTag,
|
|
63
63
|
normalizeFrontMatterTags,
|
|
64
64
|
groupTaggedItems,
|
|
65
|
+
getTagVisibility,
|
|
65
66
|
} from './tags';
|
|
66
67
|
export {
|
|
67
68
|
parseMarkdownHeadingId,
|
|
69
|
+
escapeMarkdownHeadingIds,
|
|
70
|
+
unwrapMdxCodeBlocks,
|
|
71
|
+
admonitionTitleToDirectiveLabel,
|
|
68
72
|
createExcerpt,
|
|
69
73
|
parseFrontMatter,
|
|
70
74
|
parseMarkdownContentTitle,
|
|
@@ -103,4 +107,5 @@ export {
|
|
|
103
107
|
findFolderContainingFile,
|
|
104
108
|
getFolderContainingFile,
|
|
105
109
|
} from './dataFileUtils';
|
|
110
|
+
export {isDraft, isUnlisted} from './contentVisibilityUtils';
|
|
106
111
|
export {escapeRegexp} from './regExpUtils';
|
package/src/jsUtils.ts
CHANGED
|
@@ -5,6 +5,16 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/** Adds a given string prefix to `str`. */
|
|
9
|
+
export function addPrefix(str: string, prefix: string): string {
|
|
10
|
+
return str.startsWith(prefix) ? str : `${prefix}${str}`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Adds a given string suffix to `str`. */
|
|
14
|
+
export function addSuffix(str: string, suffix: string): string {
|
|
15
|
+
return str.endsWith(suffix) ? str : `${str}${suffix}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
8
18
|
/** Removes a given string suffix from `str`. */
|
|
9
19
|
export function removeSuffix(str: string, suffix: string): string {
|
|
10
20
|
if (suffix === '') {
|
package/src/markdownLinks.ts
CHANGED
|
@@ -40,6 +40,24 @@ export type BrokenMarkdownLink<T extends ContentPaths> = {
|
|
|
40
40
|
link: string;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
type CodeFence = {
|
|
44
|
+
type: '`' | '~';
|
|
45
|
+
definitelyOpen: boolean;
|
|
46
|
+
count: number;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
function parseCodeFence(line: string): CodeFence | null {
|
|
50
|
+
const match = line.trim().match(/^(?<fence>`{3,}|~{3,})(?<rest>.*)/);
|
|
51
|
+
if (!match) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
type: match.groups!.fence![0]! as '`' | '~',
|
|
56
|
+
definitelyOpen: !!match.groups!.rest!,
|
|
57
|
+
count: match.groups!.fence!.length,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
43
61
|
/**
|
|
44
62
|
* Takes a Markdown file and replaces relative file references with their URL
|
|
45
63
|
* counterparts, e.g. `[link](./intro.md)` => `[link](/docs/intro)`, preserving
|
|
@@ -82,21 +100,23 @@ export function replaceMarkdownLinks<T extends ContentPaths>({
|
|
|
82
100
|
const brokenMarkdownLinks: BrokenMarkdownLink<T>[] = [];
|
|
83
101
|
|
|
84
102
|
// Replace internal markdown linking (except in fenced blocks).
|
|
85
|
-
let
|
|
86
|
-
let lastCodeFence = '';
|
|
103
|
+
let lastOpenCodeFence: CodeFence | null = null;
|
|
87
104
|
const lines = fileString.split('\n').map((line) => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (!
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
105
|
+
const codeFence = parseCodeFence(line);
|
|
106
|
+
if (codeFence) {
|
|
107
|
+
if (!lastOpenCodeFence) {
|
|
108
|
+
lastOpenCodeFence = codeFence;
|
|
109
|
+
} else if (
|
|
110
|
+
!codeFence.definitelyOpen &&
|
|
111
|
+
lastOpenCodeFence.type === codeFence.type &&
|
|
112
|
+
lastOpenCodeFence.count <= codeFence.count
|
|
113
|
+
) {
|
|
114
|
+
// All three conditions must be met in order for this to be considered
|
|
115
|
+
// a closing fence.
|
|
116
|
+
lastOpenCodeFence = null;
|
|
97
117
|
}
|
|
98
118
|
}
|
|
99
|
-
if (
|
|
119
|
+
if (lastOpenCodeFence) {
|
|
100
120
|
return line;
|
|
101
121
|
}
|
|
102
122
|
|
|
@@ -104,12 +124,26 @@ export function replaceMarkdownLinks<T extends ContentPaths>({
|
|
|
104
124
|
// Replace inline-style links or reference-style links e.g:
|
|
105
125
|
// This is [Document 1](doc1.md)
|
|
106
126
|
// [doc1]: doc1.md
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
127
|
+
const linkTitlePattern = '(?:\\s+(?:\'.*?\'|".*?"|\\(.*?\\)))?';
|
|
128
|
+
const linkSuffixPattern = '(?:\\?[^#>\\s]+)?(?:#[^>\\s]+)?';
|
|
129
|
+
const linkCapture = (forbidden: string) =>
|
|
130
|
+
`((?!https?://|@site/)[^${forbidden}#?]+)`;
|
|
131
|
+
const linkURLPattern = `(?:${linkCapture(
|
|
132
|
+
'()\\s',
|
|
133
|
+
)}${linkSuffixPattern}|<${linkCapture('>')}${linkSuffixPattern}>)`;
|
|
134
|
+
const linkPattern = new RegExp(
|
|
135
|
+
`\\[(?:(?!\\]\\().)*\\]\\(\\s*${linkURLPattern}${linkTitlePattern}\\s*\\)|^\\s*\\[[^[\\]]*[^[\\]\\s][^[\\]]*\\]:\\s*${linkURLPattern}${linkTitlePattern}$`,
|
|
136
|
+
'dgm',
|
|
137
|
+
);
|
|
138
|
+
let mdMatch = linkPattern.exec(modifiedLine);
|
|
110
139
|
while (mdMatch !== null) {
|
|
111
140
|
// Replace it to correct html link.
|
|
112
|
-
const mdLink = mdMatch.
|
|
141
|
+
const mdLink = mdMatch.slice(1, 5).find(Boolean)!;
|
|
142
|
+
const mdLinkRange = mdMatch.indices!.slice(1, 5).find(Boolean)!;
|
|
143
|
+
if (!/\.mdx?$/.test(mdLink)) {
|
|
144
|
+
mdMatch = linkPattern.exec(modifiedLine);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
113
147
|
|
|
114
148
|
const sourcesToTry: string[] = [];
|
|
115
149
|
// ./file.md and ../file.md are always relative to the current file
|
|
@@ -137,13 +171,13 @@ export function replaceMarkdownLinks<T extends ContentPaths>({
|
|
|
137
171
|
.split('/')
|
|
138
172
|
.map((part) => part.replace(/\s/g, '%20'))
|
|
139
173
|
.join('/');
|
|
140
|
-
modifiedLine = modifiedLine.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
)
|
|
174
|
+
modifiedLine = `${modifiedLine.slice(
|
|
175
|
+
0,
|
|
176
|
+
mdLinkRange[0],
|
|
177
|
+
)}${encodedPermalink}${modifiedLine.slice(mdLinkRange[1])}`;
|
|
144
178
|
// Adjust the lastIndex to avoid passing over the next link if the
|
|
145
179
|
// newly replaced URL is shorter.
|
|
146
|
-
|
|
180
|
+
linkPattern.lastIndex += encodedPermalink.length - mdLink.length;
|
|
147
181
|
} else {
|
|
148
182
|
const brokenMarkdownLink: BrokenMarkdownLink<T> = {
|
|
149
183
|
contentPaths,
|
|
@@ -153,7 +187,7 @@ export function replaceMarkdownLinks<T extends ContentPaths>({
|
|
|
153
187
|
|
|
154
188
|
brokenMarkdownLinks.push(brokenMarkdownLink);
|
|
155
189
|
}
|
|
156
|
-
mdMatch =
|
|
190
|
+
mdMatch = linkPattern.exec(modifiedLine);
|
|
157
191
|
}
|
|
158
192
|
return modifiedLine;
|
|
159
193
|
});
|
package/src/markdownUtils.ts
CHANGED
|
@@ -39,6 +39,75 @@ export function parseMarkdownHeadingId(heading: string): {
|
|
|
39
39
|
return {text: heading, id: undefined};
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* MDX 2 requires escaping { with a \ so our anchor syntax need that now.
|
|
44
|
+
* See https://mdxjs.com/docs/troubleshooting-mdx/#could-not-parse-expression-with-acorn-error
|
|
45
|
+
*/
|
|
46
|
+
export function escapeMarkdownHeadingIds(content: string): string {
|
|
47
|
+
const markdownHeadingRegexp = /(?:^|\n)#{1,6}(?!#).*/g;
|
|
48
|
+
return content.replaceAll(markdownHeadingRegexp, (substring) =>
|
|
49
|
+
// TODO probably not the most efficient impl...
|
|
50
|
+
substring
|
|
51
|
+
.replace('{#', '\\{#')
|
|
52
|
+
// prevent duplicate escaping
|
|
53
|
+
.replace('\\\\{#', '\\{#'),
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Hacky temporary escape hatch for Crowdin bad MDX support
|
|
59
|
+
* See https://docusaurus.io/docs/i18n/crowdin#mdx
|
|
60
|
+
*
|
|
61
|
+
* TODO Titus suggested a clean solution based on ```mdx eval and Remark
|
|
62
|
+
* See https://github.com/mdx-js/mdx/issues/701#issuecomment-947030041
|
|
63
|
+
*
|
|
64
|
+
* @param content
|
|
65
|
+
*/
|
|
66
|
+
export function unwrapMdxCodeBlocks(content: string): string {
|
|
67
|
+
// We only support 3/4 backticks on purpose, should be good enough
|
|
68
|
+
const regexp3 =
|
|
69
|
+
/(?<begin>^|\n)```mdx-code-block\n(?<children>.*?)\n```(?<end>\n|$)/gs;
|
|
70
|
+
const regexp4 =
|
|
71
|
+
/(?<begin>^|\n)````mdx-code-block\n(?<children>.*?)\n````(?<end>\n|$)/gs;
|
|
72
|
+
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
|
+
const replacer = (substring: string, ...args: any[]) => {
|
|
75
|
+
const groups = args.at(-1);
|
|
76
|
+
return `${groups.begin}${groups.children}${groups.end}`;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return content.replaceAll(regexp3, replacer).replaceAll(regexp4, replacer);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Add support for our legacy ":::note Title" admonition syntax
|
|
84
|
+
* Not supported by https://github.com/remarkjs/remark-directive
|
|
85
|
+
* Syntax is transformed to ":::note[Title]" (container directive label)
|
|
86
|
+
* See https://talk.commonmark.org/t/generic-directives-plugins-syntax/444
|
|
87
|
+
*
|
|
88
|
+
* @param content
|
|
89
|
+
* @param admonitionContainerDirectives
|
|
90
|
+
*/
|
|
91
|
+
export function admonitionTitleToDirectiveLabel(
|
|
92
|
+
content: string,
|
|
93
|
+
admonitionContainerDirectives: string[],
|
|
94
|
+
): string {
|
|
95
|
+
// this will also process ":::note Title" inside docs code blocks
|
|
96
|
+
// good enough: we fixed older versions docs to not be affected
|
|
97
|
+
|
|
98
|
+
const directiveNameGroup = `(${admonitionContainerDirectives.join('|')})`;
|
|
99
|
+
const regexp = new RegExp(
|
|
100
|
+
`^(?<directive>:{3,}${directiveNameGroup}) +(?<title>.*)$`,
|
|
101
|
+
'gm',
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
return content.replaceAll(regexp, (substring, ...args: any[]) => {
|
|
105
|
+
const groups = args.at(-1);
|
|
106
|
+
|
|
107
|
+
return `${groups.directive}[${groups.title}]`;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
42
111
|
// TODO: Find a better way to do so, possibly by compiling the Markdown content,
|
|
43
112
|
// stripping out HTML tags and obtaining the first line.
|
|
44
113
|
/**
|
|
@@ -100,7 +169,7 @@ export function createExcerpt(fileString: string): string | undefined {
|
|
|
100
169
|
// Remove Title headers
|
|
101
170
|
.replace(/^#[^#]+#?/gm, '')
|
|
102
171
|
// Remove Markdown + ATX-style headers
|
|
103
|
-
.replace(/^#{1,6}\s*(?<text>[^#]
|
|
172
|
+
.replace(/^#{1,6}\s*(?<text>[^#]*?)\s*#{0,6}/gm, '$1')
|
|
104
173
|
// Remove emphasis.
|
|
105
174
|
.replace(/(?<opening>[*_]{1,3})(?<text>.*?)\1/g, '$2')
|
|
106
175
|
// Remove strikethroughs.
|