@docusaurus/utils 0.0.0-4523 → 0.0.0-4527
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/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +10 -10
- package/lib/index.js.map +1 -1
- package/lib/markdownLinks.d.ts.map +1 -1
- package/lib/markdownLinks.js +8 -5
- package/lib/markdownLinks.js.map +1 -1
- package/lib/markdownParser.d.ts.map +1 -1
- package/lib/markdownParser.js +33 -32
- package/lib/markdownParser.js.map +1 -1
- package/lib/pathUtils.d.ts +14 -1
- package/lib/pathUtils.d.ts.map +1 -1
- package/lib/pathUtils.js +19 -11
- package/lib/pathUtils.js.map +1 -1
- package/lib/tags.d.ts +8 -0
- package/lib/tags.d.ts.map +1 -1
- package/lib/tags.js +13 -9
- package/lib/tags.js.map +1 -1
- package/lib/urlUtils.d.ts.map +1 -1
- package/lib/urlUtils.js +9 -7
- package/lib/urlUtils.js.map +1 -1
- package/lib/webpackUtils.d.ts.map +1 -1
- package/lib/webpackUtils.js +9 -8
- package/lib/webpackUtils.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +15 -14
- package/src/markdownLinks.ts +8 -5
- package/src/markdownParser.ts +33 -30
- package/src/pathUtils.ts +19 -11
- package/src/tags.ts +13 -9
- package/src/urlUtils.ts +9 -7
- package/src/webpackUtils.ts +9 -8
package/lib/index.d.ts
CHANGED
|
@@ -50,7 +50,8 @@ export declare function getPluginI18nPath({ siteDir, locale, pluginName, pluginI
|
|
|
50
50
|
/**
|
|
51
51
|
* @param permalink The URL that the HTML file corresponds to, without base URL
|
|
52
52
|
* @param outDir Full path to the output directory
|
|
53
|
-
* @param trailingSlash The site config option. If provided, only one path will
|
|
53
|
+
* @param trailingSlash The site config option. If provided, only one path will
|
|
54
|
+
* be read.
|
|
54
55
|
* @returns This returns a buffer, which you have to decode string yourself if
|
|
55
56
|
* needed. (Not always necessary since the output isn't for human consumption
|
|
56
57
|
* anyways, and most HTML manipulation libs accept buffers)
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAQH,OAAO,KAAK,EACV,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAO3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAGhC,wBAAsB,QAAQ,CAC5B,iBAAiB,EAAE,MAAM,EACzB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,OAA+C,GACzD,OAAO,CAAC,IAAI,CAAC,CA2Bf;AAKD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKnD;AAGD;;GAEG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,MAAM,EACtB,OAAO,GAAE,OAA+C,GACvD,MAAM,CAiBR;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAWpD;AAGD,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjE;AACD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,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
CHANGED
|
@@ -53,8 +53,8 @@ async function generate(generatedFilesDir, file, content, skipCache = process.en
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
exports.generate = generate;
|
|
56
|
-
const indexRE = /(
|
|
57
|
-
const extRE = /\.(
|
|
56
|
+
const indexRE = /(?<dirname>^|.*\/)index\.(?:mdx?|jsx?|tsx?)$/i;
|
|
57
|
+
const extRE = /\.(?:mdx?|jsx?|tsx?)$/;
|
|
58
58
|
/**
|
|
59
59
|
* Convert filepath to url path.
|
|
60
60
|
* Example: 'index.md' -> '/', 'foo/bar.js' -> '/foo/bar',
|
|
@@ -160,7 +160,8 @@ function getElementsAround(array, aroundIndex) {
|
|
|
160
160
|
exports.getElementsAround = getElementsAround;
|
|
161
161
|
function getPluginI18nPath({ siteDir, locale, pluginName, pluginId = constants_1.DEFAULT_PLUGIN_ID, subPaths = [], }) {
|
|
162
162
|
return path_1.default.join(siteDir, 'i18n',
|
|
163
|
-
// namespace first by locale: convenient to work in a single folder for a
|
|
163
|
+
// namespace first by locale: convenient to work in a single folder for a
|
|
164
|
+
// translator
|
|
164
165
|
locale,
|
|
165
166
|
// Make it convenient to use for single-instance
|
|
166
167
|
// ie: return "docs", not "docs-default" nor "docs/default"
|
|
@@ -170,7 +171,8 @@ exports.getPluginI18nPath = getPluginI18nPath;
|
|
|
170
171
|
/**
|
|
171
172
|
* @param permalink The URL that the HTML file corresponds to, without base URL
|
|
172
173
|
* @param outDir Full path to the output directory
|
|
173
|
-
* @param trailingSlash The site config option. If provided, only one path will
|
|
174
|
+
* @param trailingSlash The site config option. If provided, only one path will
|
|
175
|
+
* be read.
|
|
174
176
|
* @returns This returns a buffer, which you have to decode string yourself if
|
|
175
177
|
* needed. (Not always necessary since the output isn't for human consumption
|
|
176
178
|
* anyways, and most HTML manipulation libs accept buffers)
|
|
@@ -184,13 +186,11 @@ async function readOutputHTMLFile(permalink, outDir, trailingSlash) {
|
|
|
184
186
|
else if (trailingSlash === false) {
|
|
185
187
|
return fs_extra_1.default.readFile(withoutTrailingSlashPath);
|
|
186
188
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
throw new Error(`Expected output HTML file to be found at ${withTrailingSlashPath}`);
|
|
191
|
-
}
|
|
192
|
-
return fs_extra_1.default.readFile(HTMLPath);
|
|
189
|
+
const HTMLPath = await findAsyncSequential([withTrailingSlashPath, withoutTrailingSlashPath], fs_extra_1.default.pathExists);
|
|
190
|
+
if (!HTMLPath) {
|
|
191
|
+
throw new Error(`Expected output HTML file to be found at ${withTrailingSlashPath}`);
|
|
193
192
|
}
|
|
193
|
+
return fs_extra_1.default.readFile(HTMLPath);
|
|
194
194
|
}
|
|
195
195
|
exports.readOutputHTMLFile = readOutputHTMLFile;
|
|
196
196
|
async function mapAsyncSequential(array, action) {
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,6EAAwC;AACxC,6DAAwB;AACxB,mCAAkC;AAClC,mCAAiC;AACjC,qEAA0B;AAC1B,6BAAwB;AAOxB,qFAAqD;AAErD,2CAAiD;AACjD,2CAA8C;AAE9C,2DAA4B;AAC5B,0DAA2B;AAC3B,sDAAuB;AACvB,gEAAiC;AACjC,+DAAgC;AAChC,yDAA0B;AAC1B,2DAA4B;AAC5B,2DAA4B;AAC5B,2DAA4B;AAC5B,8DAA+B;AAC/B,+DAAgC;AAEhC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;AACpC,KAAK,UAAU,QAAQ,CAC5B,iBAAyB,EACzB,IAAY,EACZ,OAAe,EACf,YAAqB,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;IAE1D,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;IAEpD,IAAI,SAAS,EAAE;QACb,MAAM,kBA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AAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C,CAAC;AAEF,oBAAY,0BAA0B,CAAC,CAAC,SAAS,YAAY,IAAI;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;CAC9C,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,YAAY,EAAE,EAC3D,OAAO,EACP,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,iBAAiB,GAClB,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAAG,0BAA0B,CAAC,CAAC,CAAC,CA0E/D"}
|
package/lib/markdownLinks.js
CHANGED
|
@@ -21,7 +21,8 @@ function replaceMarkdownLinks({ siteDir, fileString, filePath, contentPaths, sou
|
|
|
21
21
|
if (!fencedBlock) {
|
|
22
22
|
fencedBlock = true;
|
|
23
23
|
[lastCodeFence] = line.trim().match(/^`+/);
|
|
24
|
-
// If we are in a ````-fenced block, all ``` would be plain text instead
|
|
24
|
+
// If we are in a ````-fenced block, all ``` would be plain text instead
|
|
25
|
+
// of fences
|
|
25
26
|
}
|
|
26
27
|
else if (line.trim().match(/^`+/)[0].length >= lastCodeFence.length) {
|
|
27
28
|
fencedBlock = false;
|
|
@@ -32,13 +33,14 @@ function replaceMarkdownLinks({ siteDir, fileString, filePath, contentPaths, sou
|
|
|
32
33
|
}
|
|
33
34
|
let modifiedLine = line;
|
|
34
35
|
// Replace inline-style links or reference-style links e.g:
|
|
35
|
-
// This is [Document 1](doc1.md) -> we replace this doc1.md with correct
|
|
36
|
+
// This is [Document 1](doc1.md) -> we replace this doc1.md with correct
|
|
37
|
+
// ink
|
|
36
38
|
// [doc1]: doc1.md -> we replace this doc1.md with correct link
|
|
37
|
-
const mdRegex = /(?:(?:\]\()|(?:\]:\s?))(?!https?:\/\/|@site\/)([^'")\]\s>]+\.mdx?)/g;
|
|
39
|
+
const mdRegex = /(?:(?:\]\()|(?:\]:\s?))(?!https?:\/\/|@site\/)(?<filename>[^'")\]\s>]+\.mdx?)/g;
|
|
38
40
|
let mdMatch = mdRegex.exec(modifiedLine);
|
|
39
41
|
while (mdMatch !== null) {
|
|
40
42
|
// Replace it to correct html link.
|
|
41
|
-
const mdLink = mdMatch
|
|
43
|
+
const mdLink = mdMatch.groups.filename;
|
|
42
44
|
const sourcesToTry = [
|
|
43
45
|
path_1.default.resolve(path_1.default.dirname(filePath), decodeURIComponent(mdLink)),
|
|
44
46
|
`${contentPathLocalized}/${decodeURIComponent(mdLink)}`,
|
|
@@ -51,7 +53,8 @@ function replaceMarkdownLinks({ siteDir, fileString, filePath, contentPaths, sou
|
|
|
51
53
|
? sourceToPermalink[aliasedSourceMatch]
|
|
52
54
|
: undefined;
|
|
53
55
|
if (permalink) {
|
|
54
|
-
// MDX won't be happy if the permalink contains a space, we need to
|
|
56
|
+
// MDX won't be happy if the permalink contains a space, we need to
|
|
57
|
+
// convert it to %20
|
|
55
58
|
const encodedPermalink = permalink
|
|
56
59
|
.split('/')
|
|
57
60
|
.map((part) => part.replace(/\s/g, '%20'))
|
package/lib/markdownLinks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownLinks.js","sourceRoot":"","sources":["../src/markdownLinks.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,6DAAwB;AACxB,2CAA4C;AA0B5C,SAAgB,oBAAoB,CAAyB,EAC3D,OAAO,EACP,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,iBAAiB,GACa;IAC9B,MAAM,EAAC,WAAW,EAAE,oBAAoB,EAAC,GAAG,YAAY,CAAC;IAEzD,MAAM,mBAAmB,GAA4B,EAAE,CAAC;IAExD,+DAA+D;IAC/D,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,aAAa,GAAG,EAAE,CAAC;IACvB,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,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,EAAE,gBAAgB,CAAC,CAAC;aAC/D;iBAAM;gBACL,MAAM,kBAAkB,GAA0B;oBAChD,YAAY;oBACZ,QAAQ;oBACR,IAAI,EAAE,MAAM;iBACb,CAAC;gBAEF,mBAAmB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;aAC9C;YACD,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SACtC;QACD,OAAO,YAAY,CAAC;IACtB,CAAC,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEpC,OAAO,EAAC,UAAU,EAAE,mBAAmB,EAAC,CAAC;AAC3C,CAAC;AAhFD,oDAgFC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownParser.d.ts","sourceRoot":"","sources":["../src/markdownParser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,
|
|
1
|
+
{"version":3,"file":"markdownParser.d.ts","sourceRoot":"","sources":["../src/markdownParser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAUA;AAKD,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA0EpE;AAED,wBAAgB,gBAAgB,CAAC,mBAAmB,EAAE,MAAM,GAAG;IAC7D,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB,CAMA;AAcD,wBAAgB,yBAAyB,CACvC,gBAAgB,EAAE,MAAM,EACxB,OAAO,CAAC,EAAE;IAAC,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAC,GACvC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;CAAC,CAkCrD;AAED,aAAK,cAAc,GAAG;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,wBAAgB,mBAAmB,CACjC,mBAAmB,EAAE,MAAM,EAC3B,OAAO,CAAC,EAAE;IAAC,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAC,GACvC,cAAc,CAuBhB"}
|
package/lib/markdownParser.js
CHANGED
|
@@ -13,17 +13,15 @@ const gray_matter_1 = (0, tslib_1.__importDefault)(require("gray-matter"));
|
|
|
13
13
|
// Input: ## Some heading {#some-heading}
|
|
14
14
|
// Output: {text: "## Some heading", id: "some-heading"}
|
|
15
15
|
function parseMarkdownHeadingId(heading) {
|
|
16
|
-
const customHeadingIdRegex = /^(
|
|
16
|
+
const customHeadingIdRegex = /^(?<text>.*?)\s*\{#(?<id>[\w-]+)\}$/;
|
|
17
17
|
const matches = customHeadingIdRegex.exec(heading);
|
|
18
18
|
if (matches) {
|
|
19
19
|
return {
|
|
20
|
-
text: matches
|
|
21
|
-
id: matches
|
|
20
|
+
text: matches.groups.text,
|
|
21
|
+
id: matches.groups.id,
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
return { text: heading, id: undefined };
|
|
26
|
-
}
|
|
24
|
+
return { text: heading, id: undefined };
|
|
27
25
|
}
|
|
28
26
|
exports.parseMarkdownHeadingId = parseMarkdownHeadingId;
|
|
29
27
|
// Hacky way of stripping out import statements from the excerpt
|
|
@@ -45,7 +43,7 @@ function createExcerpt(fileString) {
|
|
|
45
43
|
continue;
|
|
46
44
|
}
|
|
47
45
|
// Skip import/export declaration.
|
|
48
|
-
if (
|
|
46
|
+
if (/^(?:import|export)\s.*/.test(fileLine)) {
|
|
49
47
|
continue;
|
|
50
48
|
}
|
|
51
49
|
// Skip code block line.
|
|
@@ -53,7 +51,8 @@ function createExcerpt(fileString) {
|
|
|
53
51
|
if (!inCode) {
|
|
54
52
|
inCode = true;
|
|
55
53
|
[lastCodeFence] = fileLine.trim().match(/^`+/);
|
|
56
|
-
// If we are in a ````-fenced block, all ``` would be plain text instead
|
|
54
|
+
// If we are in a ````-fenced block, all ``` would be plain text instead
|
|
55
|
+
// of fences
|
|
57
56
|
}
|
|
58
57
|
else if (fileLine.trim().match(/^`+/)[0].length >= lastCodeFence.length) {
|
|
59
58
|
inCode = false;
|
|
@@ -67,25 +66,27 @@ function createExcerpt(fileString) {
|
|
|
67
66
|
// Remove HTML tags.
|
|
68
67
|
.replace(/<[^>]*>/g, '')
|
|
69
68
|
// Remove Title headers
|
|
70
|
-
.replace(/^#\s*
|
|
69
|
+
.replace(/^#\s*[^#]*\s*#?/gm, '')
|
|
71
70
|
// Remove Markdown + ATX-style headers
|
|
72
|
-
.replace(/^#{1,6}\s*([^#]*)\s*(
|
|
73
|
-
// Remove emphasis
|
|
74
|
-
.replace(/([*_
|
|
71
|
+
.replace(/^#{1,6}\s*(?<text>[^#]*)\s*(?:#{1,6})?/gm, '$1')
|
|
72
|
+
// Remove emphasis.
|
|
73
|
+
.replace(/(?<opening>[*_]{1,3})(?<text>.*?)\1/g, '$2')
|
|
74
|
+
// Remove strikethroughs.
|
|
75
|
+
.replace(/~~(?<text>\S.*\S)~~/g, '$1')
|
|
75
76
|
// Remove images.
|
|
76
|
-
.replace(/!\[(
|
|
77
|
+
.replace(/!\[(?<alt>.*?)\][[(].*?[\])]/g, '$1')
|
|
77
78
|
// Remove footnotes.
|
|
78
|
-
.replace(/\[\^.+?\](
|
|
79
|
+
.replace(/\[\^.+?\](?:: .*?$)?/g, '')
|
|
79
80
|
// Remove inline links.
|
|
80
|
-
.replace(/\[(
|
|
81
|
+
.replace(/\[(?<alt>.*?)\][[(].*?[\])]/g, '$1')
|
|
81
82
|
// Remove inline code.
|
|
82
|
-
.replace(/`(
|
|
83
|
+
.replace(/`(?<text>.+?)`/g, '$1')
|
|
83
84
|
// Remove blockquotes.
|
|
84
85
|
.replace(/^\s{0,3}>\s?/g, '')
|
|
85
86
|
// Remove admonition definition.
|
|
86
|
-
.replace(
|
|
87
|
+
.replace(/:::.*/, '')
|
|
87
88
|
// Remove Emoji names within colons include preceding whitespace.
|
|
88
|
-
.replace(/\s
|
|
89
|
+
.replace(/\s?:(?:::|[^:\n])+:/g, '')
|
|
89
90
|
// Remove custom Markdown heading id.
|
|
90
91
|
.replace(/{#*[\w-]+}/, '')
|
|
91
92
|
.trim();
|
|
@@ -104,9 +105,11 @@ function parseFrontMatter(markdownFileContent) {
|
|
|
104
105
|
};
|
|
105
106
|
}
|
|
106
107
|
exports.parseFrontMatter = parseFrontMatter;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
/**
|
|
109
|
+
* Try to convert markdown heading to text. Does not need to be perfect, it is
|
|
110
|
+
* only used as a fallback when frontMatter.title is not provided. For now, we
|
|
111
|
+
* just unwrap possible inline code blocks (# `config.js`)
|
|
112
|
+
*/
|
|
110
113
|
function toTextContentTitle(contentTitle) {
|
|
111
114
|
if (contentTitle.startsWith('`') && contentTitle.endsWith('`')) {
|
|
112
115
|
return contentTitle.substring(1, contentTitle.length - 1);
|
|
@@ -117,8 +120,8 @@ function parseMarkdownContentTitle(contentUntrimmed, options) {
|
|
|
117
120
|
var _a, _b;
|
|
118
121
|
const removeContentTitleOption = (_a = options === null || options === void 0 ? void 0 : options.removeContentTitle) !== null && _a !== void 0 ? _a : false;
|
|
119
122
|
const content = contentUntrimmed.trim();
|
|
120
|
-
const IMPORT_STATEMENT = /import\s+(
|
|
121
|
-
const REGULAR_TITLE = /(?<pattern>#\s*(?<title>[^#\n{]*)+[ \t]*(?<suffix>({#*[\w-]+})|#)?\n*?)/
|
|
123
|
+
const IMPORT_STATEMENT = /import\s+(?:[\w*{}\s\n,]+from\s+)?["'\s][@\w/_.-]+["'\s];?|\n/.source;
|
|
124
|
+
const REGULAR_TITLE = /(?<pattern>#\s*(?<title>[^#\n{]*)+[ \t]*(?<suffix>(?:{#*[\w-]+})|#)?\n*?)/
|
|
122
125
|
.source;
|
|
123
126
|
const ALTERNATE_TITLE = /(?<pattern>\s*(?<title>[^\n]*)\s*\n[=]+)/.source;
|
|
124
127
|
const regularTitleMatch = new RegExp(`^(?:${IMPORT_STATEMENT})*?${REGULAR_TITLE}`, 'g').exec(content);
|
|
@@ -128,15 +131,13 @@ function parseMarkdownContentTitle(contentUntrimmed, options) {
|
|
|
128
131
|
if (!pattern || !title) {
|
|
129
132
|
return { content, contentTitle: undefined };
|
|
130
133
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
};
|
|
139
|
-
}
|
|
134
|
+
const newContent = removeContentTitleOption
|
|
135
|
+
? content.replace(pattern, '')
|
|
136
|
+
: content;
|
|
137
|
+
return {
|
|
138
|
+
content: newContent.trim(),
|
|
139
|
+
contentTitle: toTextContentTitle(title.trim()).trim(),
|
|
140
|
+
};
|
|
140
141
|
}
|
|
141
142
|
exports.parseMarkdownContentTitle = parseMarkdownContentTitle;
|
|
142
143
|
function parseMarkdownString(markdownFileContent, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownParser.js","sourceRoot":"","sources":["../src/markdownParser.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,6EAAwC;AACxC,2EAAiC;AAEjC,yCAAyC;AACzC,wDAAwD;AACxD,SAAgB,sBAAsB,CAAC,OAAe;IAIpD,MAAM,oBAAoB,GAAG,
|
|
1
|
+
{"version":3,"file":"markdownParser.js","sourceRoot":"","sources":["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AAO,EAAE,KAAK,EAAC,GAAG,MAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,MAAM,mCAAI,EAAE,CAAC;IAElD,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,EAAE;QACtB,OAAO,EAAC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAC,CAAC;KAC3C;IACD,MAAM,UAAU,GAAG,wBAAwB;QACzC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAC9B,CAAC,CAAC,OAAO,CAAC;IACZ,OAAO;QACL,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE;QAC1B,YAAY,EAAE,kBAAkB,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;KACtD,CAAC;AACJ,CAAC;AArCD,8DAqCC;AASD,SAAgB,mBAAmB,CACjC,mBAA2B,EAC3B,OAAwC;IAExC,IAAI;QACF,MAAM,EAAC,WAAW,EAAE,OAAO,EAAE,yBAAyB,EAAC,GACrD,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;QAExC,MAAM,EAAC,OAAO,EAAE,YAAY,EAAC,GAAG,yBAAyB,CACvD,yBAAyB,EACzB,OAAO,CACR,CAAC;QAEF,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;QAEvC,OAAO;YACL,WAAW;YACX,OAAO;YACP,YAAY;YACZ,OAAO;SACR,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,gBAAM,CAAC,KAAK,CAAC;kHACiG,CAAC,CAAC;QAChH,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AA1BD,kDA0BC"}
|
package/lib/pathUtils.d.ts
CHANGED
|
@@ -17,6 +17,18 @@ export declare const shortName: (str: string) => string;
|
|
|
17
17
|
* Adopted from https://github.com/sindresorhus/slash/blob/main/index.js
|
|
18
18
|
*/
|
|
19
19
|
export declare function posixPath(str: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* When you want to display a path in a message/warning/error, it's more
|
|
22
|
+
* convenient to:
|
|
23
|
+
*
|
|
24
|
+
* - make it relative to `cwd()`
|
|
25
|
+
* - convert to posix (ie not using windows \ path separator)
|
|
26
|
+
*
|
|
27
|
+
* This way, Jest tests can run more reliably on any computer/CI on both
|
|
28
|
+
* Unix/Windows
|
|
29
|
+
* For Windows users this is not perfect (as they see / instead of \) but it's
|
|
30
|
+
* probably good enough
|
|
31
|
+
*/
|
|
20
32
|
export declare function toMessageRelativeFilePath(filePath: string): string;
|
|
21
33
|
/**
|
|
22
34
|
* Alias filepath relative to site directory, very useful so that we
|
|
@@ -27,7 +39,8 @@ export declare function aliasedSitePath(filePath: string, siteDir: string): stri
|
|
|
27
39
|
/**
|
|
28
40
|
* When you have a path like C:\X\Y
|
|
29
41
|
* It is not safe to use directly when generating code
|
|
30
|
-
* For example, this would fail due to unescaped \:
|
|
42
|
+
* For example, this would fail due to unescaped \:
|
|
43
|
+
* `<img src={require('${filePath}')} />`
|
|
31
44
|
* But this would work: `<img src={require('${escapePath(filePath)}')} />`
|
|
32
45
|
*
|
|
33
46
|
* posixPath can't be used in all cases, because forward slashes are only valid
|
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;
|
|
1
|
+
{"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../src/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH,eAAO,MAAM,aAAa,QAAS,MAAM,KAAG,OAIgC,CAAC;AAE7E,eAAO,MAAM,SAAS,QAAS,MAAM,KAAG,MAiBvC,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAY7C;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;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK9C"}
|
package/lib/pathUtils.js
CHANGED
|
@@ -10,7 +10,8 @@ exports.escapePath = exports.aliasedSitePath = exports.toMessageRelativeFilePath
|
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
// Based on https://github.com/gatsbyjs/gatsby/pull/21518/files
|
|
12
12
|
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
13
|
-
// MacOS (APFS) and Windows (NTFS) filename length limit = 255 chars,
|
|
13
|
+
// MacOS (APFS) and Windows (NTFS) filename length limit = 255 chars,
|
|
14
|
+
// Others = 255 bytes
|
|
14
15
|
const MAX_PATH_SEGMENT_CHARS = 255;
|
|
15
16
|
const MAX_PATH_SEGMENT_BYTES = 255;
|
|
16
17
|
// Space for appending things to the string like file extensions and so on
|
|
@@ -18,7 +19,7 @@ const SPACE_FOR_APPENDING = 10;
|
|
|
18
19
|
const isMacOs = () => process.platform === 'darwin';
|
|
19
20
|
const isWindows = () => process.platform === 'win32';
|
|
20
21
|
const isNameTooLong = (str) =>
|
|
21
|
-
//
|
|
22
|
+
// Not entirely correct: we can't assume FS from OS. But good enough?
|
|
22
23
|
isMacOs() || isWindows()
|
|
23
24
|
? str.length + SPACE_FOR_APPENDING > MAX_PATH_SEGMENT_CHARS // MacOS (APFS) and Windows (NTFS) filename length limit (255 chars)
|
|
24
25
|
: Buffer.from(str).length + SPACE_FOR_APPENDING > MAX_PATH_SEGMENT_BYTES; // Other (255 bytes)
|
|
@@ -47,7 +48,8 @@ exports.shortName = shortName;
|
|
|
47
48
|
*/
|
|
48
49
|
function posixPath(str) {
|
|
49
50
|
const isExtendedLengthPath = /^\\\\\?\\/.test(str);
|
|
50
|
-
// Forward slashes are only valid Windows paths when they don't contain non-
|
|
51
|
+
// Forward slashes are only valid Windows paths when they don't contain non-
|
|
52
|
+
// ascii characters.
|
|
51
53
|
// eslint-disable-next-line no-control-regex
|
|
52
54
|
const hasNonAscii = /[^\u0000-\u0080]+/.test(str);
|
|
53
55
|
if (isExtendedLengthPath || hasNonAscii) {
|
|
@@ -56,13 +58,18 @@ function posixPath(str) {
|
|
|
56
58
|
return str.replace(/\\/g, '/');
|
|
57
59
|
}
|
|
58
60
|
exports.posixPath = posixPath;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
/**
|
|
62
|
+
* When you want to display a path in a message/warning/error, it's more
|
|
63
|
+
* convenient to:
|
|
64
|
+
*
|
|
65
|
+
* - make it relative to `cwd()`
|
|
66
|
+
* - convert to posix (ie not using windows \ path separator)
|
|
67
|
+
*
|
|
68
|
+
* This way, Jest tests can run more reliably on any computer/CI on both
|
|
69
|
+
* Unix/Windows
|
|
70
|
+
* For Windows users this is not perfect (as they see / instead of \) but it's
|
|
71
|
+
* probably good enough
|
|
72
|
+
*/
|
|
66
73
|
function toMessageRelativeFilePath(filePath) {
|
|
67
74
|
return posixPath(path_1.default.relative(process.cwd(), filePath));
|
|
68
75
|
}
|
|
@@ -82,7 +89,8 @@ exports.aliasedSitePath = aliasedSitePath;
|
|
|
82
89
|
/**
|
|
83
90
|
* When you have a path like C:\X\Y
|
|
84
91
|
* It is not safe to use directly when generating code
|
|
85
|
-
* For example, this would fail due to unescaped \:
|
|
92
|
+
* For example, this would fail due to unescaped \:
|
|
93
|
+
* `<img src={require('${filePath}')} />`
|
|
86
94
|
* But this would work: `<img src={require('${escapePath(filePath)}')} />`
|
|
87
95
|
*
|
|
88
96
|
* posixPath can't be used in all cases, because forward slashes are only valid
|
package/lib/pathUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathUtils.js","sourceRoot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;IACvC,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC;AALD,gCAKC"}
|
package/lib/tags.d.ts
CHANGED
|
@@ -15,5 +15,13 @@ export declare type TaggedItemGroup<Item> = {
|
|
|
15
15
|
tag: Tag;
|
|
16
16
|
items: Item[];
|
|
17
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Permits to group docs/blogPosts by tag (provided by front matter)
|
|
20
|
+
* Note: groups are indexed by permalink, because routes must be unique in the
|
|
21
|
+
* end. Labels may vary on 2 md files but they are normalized. Docs with
|
|
22
|
+
* label='some label' and label='some-label' should end-up in the same
|
|
23
|
+
* group/page in the end. We can't create 2 routes /some-label because one would
|
|
24
|
+
* override the other
|
|
25
|
+
*/
|
|
18
26
|
export declare function groupTaggedItems<Item>(items: Item[], getItemTags: (item: Item) => Tag[]): Record<string, TaggedItemGroup<Item>>;
|
|
19
27
|
//# 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,oBAAY,GAAG,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,oBAAY,cAAc,GAAG,MAAM,GAAG,GAAG,CAAC;AAE1C,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,cAAc,GAC7B,GAAG,CAyBL;AAED,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,eAAe,GAAE,cAAc,EAAE,GAAG,SAAc,GACjD,GAAG,EAAE,CAMP;AAED,oBAAY,eAAe,CAAC,IAAI,IAAI;IAClC,GAAG,EAAE,GAAG,CAAC;IACT,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;
|
|
1
|
+
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,oBAAY,GAAG,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,oBAAY,cAAc,GAAG,MAAM,GAAG,GAAG,CAAC;AAE1C,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,cAAc,GAC7B,GAAG,CAyBL;AAED,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,eAAe,GAAE,cAAc,EAAE,GAAG,SAAc,GACjD,GAAG,EAAE,CAMP;AAED,oBAAY,eAAe,CAAC,IAAI,IAAI;IAClC,GAAG,EAAE,GAAG,CAAC;IACT,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EACnC,KAAK,EAAE,IAAI,EAAE,EACb,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,GAAG,EAAE,GACjC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC,CA8BvC"}
|
package/lib/tags.js
CHANGED
|
@@ -18,9 +18,9 @@ function normalizeFrontMatterTag(tagsPath, frontMatterTag) {
|
|
|
18
18
|
}
|
|
19
19
|
// TODO maybe make ensure the permalink is valid url path?
|
|
20
20
|
function normalizeTagPermalink(permalink) {
|
|
21
|
-
// note: we always apply tagsPath on purpose
|
|
22
|
-
//
|
|
23
|
-
// tagsPath is different for each doc version
|
|
21
|
+
// note: we always apply tagsPath on purpose. For versioned docs, v1/doc.md
|
|
22
|
+
// and v2/doc.md tags with custom permalinks don't lead to the same created
|
|
23
|
+
// page. tagsPath is different for each doc version
|
|
24
24
|
return (0, urlUtils_1.normalizeUrl)([tagsPath, permalink]);
|
|
25
25
|
}
|
|
26
26
|
const tag = typeof frontMatterTag === 'string'
|
|
@@ -37,17 +37,21 @@ function normalizeFrontMatterTags(tagsPath, frontMatterTags = []) {
|
|
|
37
37
|
return (0, lodash_1.uniqBy)(tags, (tag) => tag.permalink);
|
|
38
38
|
}
|
|
39
39
|
exports.normalizeFrontMatterTags = normalizeFrontMatterTags;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Permits to group docs/blogPosts by tag (provided by front matter)
|
|
42
|
+
* Note: groups are indexed by permalink, because routes must be unique in the
|
|
43
|
+
* end. Labels may vary on 2 md files but they are normalized. Docs with
|
|
44
|
+
* label='some label' and label='some-label' should end-up in the same
|
|
45
|
+
* group/page in the end. We can't create 2 routes /some-label because one would
|
|
46
|
+
* override the other
|
|
47
|
+
*/
|
|
45
48
|
function groupTaggedItems(items, getItemTags) {
|
|
46
49
|
const result = {};
|
|
47
50
|
function handleItemTag(item, tag) {
|
|
48
51
|
var _a;
|
|
49
52
|
// Init missing tag groups
|
|
50
|
-
// TODO: it's not really clear what should be the behavior if 2 items have
|
|
53
|
+
// TODO: it's not really clear what should be the behavior if 2 items have
|
|
54
|
+
// the same tag but the permalink is different for each
|
|
51
55
|
// For now, the first tag found wins
|
|
52
56
|
result[tag.permalink] = (_a = result[tag.permalink]) !== null && _a !== void 0 ? _a : {
|
|
53
57
|
tag,
|
package/lib/tags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,mCAA+C;AAC/C,yCAAwC;AASxC,SAAgB,uBAAuB,CACrC,QAAgB,EAChB,cAA8B;IAE9B,SAAS,WAAW,CAAC,SAAiB;QACpC,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,SAAS,EAAE,IAAA,kBAAS,EAAC,SAAS,CAAC;SAChC,CAAC;IACJ,CAAC;IAED,0DAA0D;IAC1D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AAU,EAAE,GAAQ;;QACzC,0BAA0B;QAC1B,0EAA0E;QAC1E,uDAAuD;QACvD,oCAAoC;QACpC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,MAAA,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,mCAAI;YAC/C,GAAG;YACH,KAAK,EAAE,EAAE;SACV,CAAC;QAEF,oBAAoB;QACpB,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACrB,WAAW,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAChC,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,mEAAmE;IACnE,wDAAwD;IACxD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACtC,KAAK,CAAC,KAAK,GAAG,IAAA,aAAI,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAjCD,4CAiCC"}
|
package/lib/urlUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urlUtils.d.ts","sourceRoot":"","sources":["../src/urlUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"urlUtils.d.ts","sourceRoot":"","sources":["../src/urlUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CA8EtD;AAED,wBAAgB,UAAU,CACxB,gBAAgB,EAAE,MAAM,EACxB,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,GAAG,SAAS,CAKpB"}
|
package/lib/urlUtils.js
CHANGED
|
@@ -16,7 +16,8 @@ function normalizeUrl(rawUrls) {
|
|
|
16
16
|
if (urls[0].match(/^[^/:]+:\/*$/) && urls.length > 1) {
|
|
17
17
|
const first = urls.shift();
|
|
18
18
|
if (first.startsWith('file:') && urls[0].startsWith('/')) {
|
|
19
|
-
// Force a double slash here, else we lose the information that the next
|
|
19
|
+
// Force a double slash here, else we lose the information that the next
|
|
20
|
+
// segment is an absolute path
|
|
20
21
|
urls[0] = `${first}//${urls[0]}`;
|
|
21
22
|
}
|
|
22
23
|
else {
|
|
@@ -26,7 +27,7 @@ function normalizeUrl(rawUrls) {
|
|
|
26
27
|
// There must be two or three slashes in the file protocol,
|
|
27
28
|
// two slashes in anything else.
|
|
28
29
|
const replacement = urls[0].match(/^file:\/\/\//) ? '$1:///' : '$1://';
|
|
29
|
-
urls[0] = urls[0].replace(/^([^/:]+):\/*/, replacement);
|
|
30
|
+
urls[0] = urls[0].replace(/^(?<protocol>[^/:]+):\/*/, replacement);
|
|
30
31
|
for (let i = 0; i < urls.length; i += 1) {
|
|
31
32
|
let component = urls[i];
|
|
32
33
|
if (typeof component !== 'string') {
|
|
@@ -43,12 +44,13 @@ function normalizeUrl(rawUrls) {
|
|
|
43
44
|
if (i > 0) {
|
|
44
45
|
// Removing the starting slashes for each component but the first.
|
|
45
46
|
component = component.replace(/^[/]+/,
|
|
46
|
-
// Special case where the first element of rawUrls is empty
|
|
47
|
+
// Special case where the first element of rawUrls is empty
|
|
48
|
+
// ["", "/hello"] => /hello
|
|
47
49
|
component[0] === '/' && !hasStartingSlash ? '/' : '');
|
|
48
50
|
}
|
|
49
51
|
hasEndingSlash = component[component.length - 1] === '/';
|
|
50
|
-
// Removing the ending slashes for each component but the last.
|
|
51
|
-
//
|
|
52
|
+
// Removing the ending slashes for each component but the last. For the
|
|
53
|
+
// last component we will combine multiple slashes to a single one.
|
|
52
54
|
component = component.replace(/[/]+$/, i < urls.length - 1 ? '' : '/');
|
|
53
55
|
}
|
|
54
56
|
hasStartingSlash = true;
|
|
@@ -58,12 +60,12 @@ function normalizeUrl(rawUrls) {
|
|
|
58
60
|
// Each input component is now separated by a single slash
|
|
59
61
|
// except the possible first plain protocol part.
|
|
60
62
|
// Remove trailing slash before parameters or hash.
|
|
61
|
-
str = str.replace(/\/(
|
|
63
|
+
str = str.replace(/\/(?<search>\?|&|#[^!])/g, '$1');
|
|
62
64
|
// Replace ? in parameters with &.
|
|
63
65
|
const parts = str.split('?');
|
|
64
66
|
str = parts.shift() + (parts.length > 0 ? '?' : '') + parts.join('&');
|
|
65
67
|
// Dedupe forward slashes in the entire path, avoiding protocol slashes.
|
|
66
|
-
str = str.replace(/([^:/]\/)\/+/g, '$1');
|
|
68
|
+
str = str.replace(/(?<textBefore>[^:/]\/)\/+/g, '$1');
|
|
67
69
|
// Dedupe forward slashes at the beginning of the path.
|
|
68
70
|
str = str.replace(/^\/+/g, '/');
|
|
69
71
|
return 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,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,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,EAAE,CAAC;QAC3B,IAAI,KAAM,CAA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AAA;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;AAGF,wBAAgB,kBAAkB,IAAI,eAAe,
|
|
1
|
+
{"version":3,"file":"webpackUtils.d.ts","sourceRoot":"","sources":["../src/webpackUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAQzC,aAAK,WAAW,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE3D,aAAK,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;AAGF,wBAAgB,kBAAkB,IAAI,eAAe,CA8GpD"}
|
package/lib/webpackUtils.js
CHANGED
|
@@ -13,7 +13,8 @@ const pathUtils_1 = require("./pathUtils");
|
|
|
13
13
|
const constants_1 = require("./constants");
|
|
14
14
|
// Inspired by https://github.com/gatsbyjs/gatsby/blob/8e6e021014da310b9cc7d02e58c9b3efe938c665/packages/gatsby/src/utils/webpack-utils.ts#L447
|
|
15
15
|
function getFileLoaderUtils() {
|
|
16
|
-
// files/images < urlLoaderLimit will be inlined as base64 strings directly in
|
|
16
|
+
// files/images < urlLoaderLimit will be inlined as base64 strings directly in
|
|
17
|
+
// the html
|
|
17
18
|
const urlLoaderLimit = constants_1.WEBPACK_URL_LOADER_LIMIT;
|
|
18
19
|
// defines the path/pattern of the assets handled by webpack
|
|
19
20
|
const fileLoaderFileName = (folder) => `${constants_1.OUTPUT_STATIC_ASSETS_DIR_NAME}/${folder}/[name]-[hash].[ext]`;
|
|
@@ -32,7 +33,7 @@ function getFileLoaderUtils() {
|
|
|
32
33
|
fallback: require.resolve('file-loader'),
|
|
33
34
|
},
|
|
34
35
|
}),
|
|
35
|
-
// TODO
|
|
36
|
+
// TODO avoid conflicts with the ideal-image plugin
|
|
36
37
|
// TODO this may require a little breaking change for ideal-image users?
|
|
37
38
|
// Maybe with the ideal image plugin, all md images should be "ideal"?
|
|
38
39
|
// This is used to force url-loader+file-loader on markdown images
|
|
@@ -47,11 +48,11 @@ function getFileLoaderUtils() {
|
|
|
47
48
|
*/
|
|
48
49
|
images: () => ({
|
|
49
50
|
use: [loaders.url({ folder: 'images' })],
|
|
50
|
-
test: /\.(ico|
|
|
51
|
+
test: /\.(?:ico|jpe?g|png|gif|webp)(?:\?.*)?$/i,
|
|
51
52
|
}),
|
|
52
53
|
fonts: () => ({
|
|
53
54
|
use: [loaders.url({ folder: 'fonts' })],
|
|
54
|
-
test: /\.(
|
|
55
|
+
test: /\.(?:woff2?|eot|ttf|otf)$/i,
|
|
55
56
|
}),
|
|
56
57
|
/**
|
|
57
58
|
* Loads audio and video and inlines them via a data URI if they are below
|
|
@@ -59,10 +60,10 @@ function getFileLoaderUtils() {
|
|
|
59
60
|
*/
|
|
60
61
|
media: () => ({
|
|
61
62
|
use: [loaders.url({ folder: 'medias' })],
|
|
62
|
-
test: /\.(mp4|webm|ogv|wav|mp3|m4a|aac|oga|flac)
|
|
63
|
+
test: /\.(?:mp4|webm|ogv|wav|mp3|m4a|aac|oga|flac)$/i,
|
|
63
64
|
}),
|
|
64
65
|
svg: () => ({
|
|
65
|
-
test: /\.svg
|
|
66
|
+
test: /\.svg$/i,
|
|
66
67
|
oneOf: [
|
|
67
68
|
{
|
|
68
69
|
use: [
|
|
@@ -91,7 +92,7 @@ function getFileLoaderUtils() {
|
|
|
91
92
|
// We don't want to use SVGR loader for non-React source code
|
|
92
93
|
// ie we don't want to use SVGR for CSS files...
|
|
93
94
|
issuer: {
|
|
94
|
-
and: [/\.(
|
|
95
|
+
and: [/\.(?:tsx?|jsx?|mdx?)$/i],
|
|
95
96
|
},
|
|
96
97
|
},
|
|
97
98
|
{
|
|
@@ -101,7 +102,7 @@ function getFileLoaderUtils() {
|
|
|
101
102
|
}),
|
|
102
103
|
otherAssets: () => ({
|
|
103
104
|
use: [loaders.file({ folder: 'files' })],
|
|
104
|
-
test: /\.(pdf|
|
|
105
|
+
test: /\.(?:pdf|docx?|xlsx?|zip|rar)$/i,
|
|
105
106
|
}),
|
|
106
107
|
};
|
|
107
108
|
return { loaders, rules };
|
package/lib/webpackUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpackUtils.js","sourceRoot":"","sources":["../src/webpackUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAGH,6DAAwB;AACxB,2CAAuC;AACvC,2CAGqB;AAoBrB,+IAA+I;AAC/I,SAAgB,kBAAkB;IAChC,
|
|
1
|
+
{"version":3,"file":"webpackUtils.js","sourceRoot":"","sources":["../src/webpackUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAGH,6DAAwB;AACxB,2CAAuC;AACvC,2CAGqB;AAoBrB,+IAA+I;AAC/I,SAAgB,kBAAkB;I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CAAC,EAAC,MAAM,EAAE,OAAO,EAAC,CAAC,CAAC;YACtC,IAAI,EAAE,iCAAiC;SACxC,CAAC;KACH,CAAC;IAEF,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,CAAC;AAC1B,CAAC;AA9GD,gDA8GC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/utils",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-4527",
|
|
4
4
|
"description": "Node utility functions for Docusaurus packages.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/logger": "0.0.0-
|
|
21
|
+
"@docusaurus/logger": "0.0.0-4527",
|
|
22
22
|
"@mdx-js/runtime": "^1.6.22",
|
|
23
23
|
"@svgr/webpack": "^6.0.0",
|
|
24
24
|
"file-loader": "^6.2.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"node": ">=14"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@docusaurus/types": "0.0.0-
|
|
42
|
+
"@docusaurus/types": "0.0.0-4527",
|
|
43
43
|
"@types/dedent": "^0.7.0",
|
|
44
44
|
"@types/github-slugger": "^1.3.0",
|
|
45
45
|
"@types/micromatch": "^4.0.2",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"react-dom": "*",
|
|
54
54
|
"webpack": "^5.0.0"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "fdd9e4feffd46f92b4ee3c519026bff7f2de6d05"
|
|
57
57
|
}
|
package/src/index.ts
CHANGED
|
@@ -69,8 +69,8 @@ export async function generate(
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
const indexRE = /(
|
|
73
|
-
const extRE = /\.(
|
|
72
|
+
const indexRE = /(?<dirname>^|.*\/)index\.(?:mdx?|jsx?|tsx?)$/i;
|
|
73
|
+
const extRE = /\.(?:mdx?|jsx?|tsx?)$/;
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
76
|
* Convert filepath to url path.
|
|
@@ -200,7 +200,8 @@ export function getPluginI18nPath({
|
|
|
200
200
|
return path.join(
|
|
201
201
|
siteDir,
|
|
202
202
|
'i18n',
|
|
203
|
-
// namespace first by locale: convenient to work in a single folder for a
|
|
203
|
+
// namespace first by locale: convenient to work in a single folder for a
|
|
204
|
+
// translator
|
|
204
205
|
locale,
|
|
205
206
|
// Make it convenient to use for single-instance
|
|
206
207
|
// ie: return "docs", not "docs-default" nor "docs/default"
|
|
@@ -212,7 +213,8 @@ export function getPluginI18nPath({
|
|
|
212
213
|
/**
|
|
213
214
|
* @param permalink The URL that the HTML file corresponds to, without base URL
|
|
214
215
|
* @param outDir Full path to the output directory
|
|
215
|
-
* @param trailingSlash The site config option. If provided, only one path will
|
|
216
|
+
* @param trailingSlash The site config option. If provided, only one path will
|
|
217
|
+
* be read.
|
|
216
218
|
* @returns This returns a buffer, which you have to decode string yourself if
|
|
217
219
|
* needed. (Not always necessary since the output isn't for human consumption
|
|
218
220
|
* anyways, and most HTML manipulation libs accept buffers)
|
|
@@ -231,18 +233,17 @@ export async function readOutputHTMLFile(
|
|
|
231
233
|
return fs.readFile(withTrailingSlashPath);
|
|
232
234
|
} else if (trailingSlash === false) {
|
|
233
235
|
return fs.readFile(withoutTrailingSlashPath);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
}
|
|
237
|
+
const HTMLPath = await findAsyncSequential(
|
|
238
|
+
[withTrailingSlashPath, withoutTrailingSlashPath],
|
|
239
|
+
fs.pathExists,
|
|
240
|
+
);
|
|
241
|
+
if (!HTMLPath) {
|
|
242
|
+
throw new Error(
|
|
243
|
+
`Expected output HTML file to be found at ${withTrailingSlashPath}`,
|
|
238
244
|
);
|
|
239
|
-
if (!HTMLPath) {
|
|
240
|
-
throw new Error(
|
|
241
|
-
`Expected output HTML file to be found at ${withTrailingSlashPath}`,
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
return fs.readFile(HTMLPath);
|
|
245
245
|
}
|
|
246
|
+
return fs.readFile(HTMLPath);
|
|
246
247
|
}
|
|
247
248
|
|
|
248
249
|
export async function mapAsyncSequential<T, R>(
|
package/src/markdownLinks.ts
CHANGED
|
@@ -51,7 +51,8 @@ export function replaceMarkdownLinks<T extends ContentPaths>({
|
|
|
51
51
|
if (!fencedBlock) {
|
|
52
52
|
fencedBlock = true;
|
|
53
53
|
[lastCodeFence] = line.trim().match(/^`+/)!;
|
|
54
|
-
// If we are in a ````-fenced block, all ``` would be plain text instead
|
|
54
|
+
// If we are in a ````-fenced block, all ``` would be plain text instead
|
|
55
|
+
// of fences
|
|
55
56
|
} else if (line.trim().match(/^`+/)![0].length >= lastCodeFence.length) {
|
|
56
57
|
fencedBlock = false;
|
|
57
58
|
}
|
|
@@ -62,14 +63,15 @@ export function replaceMarkdownLinks<T extends ContentPaths>({
|
|
|
62
63
|
|
|
63
64
|
let modifiedLine = line;
|
|
64
65
|
// Replace inline-style links or reference-style links e.g:
|
|
65
|
-
// This is [Document 1](doc1.md) -> we replace this doc1.md with correct
|
|
66
|
+
// This is [Document 1](doc1.md) -> we replace this doc1.md with correct
|
|
67
|
+
// ink
|
|
66
68
|
// [doc1]: doc1.md -> we replace this doc1.md with correct link
|
|
67
69
|
const mdRegex =
|
|
68
|
-
/(?:(?:\]\()|(?:\]:\s?))(?!https?:\/\/|@site\/)([^'")\]\s>]+\.mdx?)/g;
|
|
70
|
+
/(?:(?:\]\()|(?:\]:\s?))(?!https?:\/\/|@site\/)(?<filename>[^'")\]\s>]+\.mdx?)/g;
|
|
69
71
|
let mdMatch = mdRegex.exec(modifiedLine);
|
|
70
72
|
while (mdMatch !== null) {
|
|
71
73
|
// Replace it to correct html link.
|
|
72
|
-
const mdLink = mdMatch
|
|
74
|
+
const mdLink = mdMatch.groups!.filename;
|
|
73
75
|
|
|
74
76
|
const sourcesToTry = [
|
|
75
77
|
path.resolve(path.dirname(filePath), decodeURIComponent(mdLink)),
|
|
@@ -86,7 +88,8 @@ export function replaceMarkdownLinks<T extends ContentPaths>({
|
|
|
86
88
|
: undefined;
|
|
87
89
|
|
|
88
90
|
if (permalink) {
|
|
89
|
-
// MDX won't be happy if the permalink contains a space, we need to
|
|
91
|
+
// MDX won't be happy if the permalink contains a space, we need to
|
|
92
|
+
// convert it to %20
|
|
90
93
|
const encodedPermalink = permalink
|
|
91
94
|
.split('/')
|
|
92
95
|
.map((part) => part.replace(/\s/g, '%20'))
|
package/src/markdownParser.ts
CHANGED
|
@@ -14,16 +14,15 @@ export function parseMarkdownHeadingId(heading: string): {
|
|
|
14
14
|
text: string;
|
|
15
15
|
id?: string;
|
|
16
16
|
} {
|
|
17
|
-
const customHeadingIdRegex = /^(
|
|
17
|
+
const customHeadingIdRegex = /^(?<text>.*?)\s*\{#(?<id>[\w-]+)\}$/;
|
|
18
18
|
const matches = customHeadingIdRegex.exec(heading);
|
|
19
19
|
if (matches) {
|
|
20
20
|
return {
|
|
21
|
-
text: matches
|
|
22
|
-
id: matches
|
|
21
|
+
text: matches.groups!.text,
|
|
22
|
+
id: matches.groups!.id,
|
|
23
23
|
};
|
|
24
|
-
} else {
|
|
25
|
-
return {text: heading, id: undefined};
|
|
26
24
|
}
|
|
25
|
+
return {text: heading, id: undefined};
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
// Hacky way of stripping out import statements from the excerpt
|
|
@@ -47,7 +46,7 @@ export function createExcerpt(fileString: string): string | undefined {
|
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
// Skip import/export declaration.
|
|
50
|
-
if (
|
|
49
|
+
if (/^(?:import|export)\s.*/.test(fileLine)) {
|
|
51
50
|
continue;
|
|
52
51
|
}
|
|
53
52
|
|
|
@@ -56,7 +55,8 @@ export function createExcerpt(fileString: string): string | undefined {
|
|
|
56
55
|
if (!inCode) {
|
|
57
56
|
inCode = true;
|
|
58
57
|
[lastCodeFence] = fileLine.trim().match(/^`+/)!;
|
|
59
|
-
// If we are in a ````-fenced block, all ``` would be plain text instead
|
|
58
|
+
// If we are in a ````-fenced block, all ``` would be plain text instead
|
|
59
|
+
// of fences
|
|
60
60
|
} else if (
|
|
61
61
|
fileLine.trim().match(/^`+/)![0].length >= lastCodeFence.length
|
|
62
62
|
) {
|
|
@@ -71,25 +71,27 @@ export function createExcerpt(fileString: string): string | undefined {
|
|
|
71
71
|
// Remove HTML tags.
|
|
72
72
|
.replace(/<[^>]*>/g, '')
|
|
73
73
|
// Remove Title headers
|
|
74
|
-
.replace(/^#\s*
|
|
74
|
+
.replace(/^#\s*[^#]*\s*#?/gm, '')
|
|
75
75
|
// Remove Markdown + ATX-style headers
|
|
76
|
-
.replace(/^#{1,6}\s*([^#]*)\s*(
|
|
77
|
-
// Remove emphasis
|
|
78
|
-
.replace(/([*_
|
|
76
|
+
.replace(/^#{1,6}\s*(?<text>[^#]*)\s*(?:#{1,6})?/gm, '$1')
|
|
77
|
+
// Remove emphasis.
|
|
78
|
+
.replace(/(?<opening>[*_]{1,3})(?<text>.*?)\1/g, '$2')
|
|
79
|
+
// Remove strikethroughs.
|
|
80
|
+
.replace(/~~(?<text>\S.*\S)~~/g, '$1')
|
|
79
81
|
// Remove images.
|
|
80
|
-
.replace(/!\[(
|
|
82
|
+
.replace(/!\[(?<alt>.*?)\][[(].*?[\])]/g, '$1')
|
|
81
83
|
// Remove footnotes.
|
|
82
|
-
.replace(/\[\^.+?\](
|
|
84
|
+
.replace(/\[\^.+?\](?:: .*?$)?/g, '')
|
|
83
85
|
// Remove inline links.
|
|
84
|
-
.replace(/\[(
|
|
86
|
+
.replace(/\[(?<alt>.*?)\][[(].*?[\])]/g, '$1')
|
|
85
87
|
// Remove inline code.
|
|
86
|
-
.replace(/`(
|
|
88
|
+
.replace(/`(?<text>.+?)`/g, '$1')
|
|
87
89
|
// Remove blockquotes.
|
|
88
90
|
.replace(/^\s{0,3}>\s?/g, '')
|
|
89
91
|
// Remove admonition definition.
|
|
90
|
-
.replace(
|
|
92
|
+
.replace(/:::.*/, '')
|
|
91
93
|
// Remove Emoji names within colons include preceding whitespace.
|
|
92
|
-
.replace(/\s
|
|
94
|
+
.replace(/\s?:(?:::|[^:\n])+:/g, '')
|
|
93
95
|
// Remove custom Markdown heading id.
|
|
94
96
|
.replace(/{#*[\w-]+}/, '')
|
|
95
97
|
.trim();
|
|
@@ -113,9 +115,11 @@ export function parseFrontMatter(markdownFileContent: string): {
|
|
|
113
115
|
};
|
|
114
116
|
}
|
|
115
117
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Try to convert markdown heading to text. Does not need to be perfect, it is
|
|
120
|
+
* only used as a fallback when frontMatter.title is not provided. For now, we
|
|
121
|
+
* just unwrap possible inline code blocks (# `config.js`)
|
|
122
|
+
*/
|
|
119
123
|
function toTextContentTitle(contentTitle: string): string {
|
|
120
124
|
if (contentTitle.startsWith('`') && contentTitle.endsWith('`')) {
|
|
121
125
|
return contentTitle.substring(1, contentTitle.length - 1);
|
|
@@ -132,9 +136,9 @@ export function parseMarkdownContentTitle(
|
|
|
132
136
|
const content = contentUntrimmed.trim();
|
|
133
137
|
|
|
134
138
|
const IMPORT_STATEMENT =
|
|
135
|
-
/import\s+(
|
|
139
|
+
/import\s+(?:[\w*{}\s\n,]+from\s+)?["'\s][@\w/_.-]+["'\s];?|\n/.source;
|
|
136
140
|
const REGULAR_TITLE =
|
|
137
|
-
/(?<pattern>#\s*(?<title>[^#\n{]*)+[ \t]*(?<suffix>({#*[\w-]+})|#)?\n*?)/
|
|
141
|
+
/(?<pattern>#\s*(?<title>[^#\n{]*)+[ \t]*(?<suffix>(?:{#*[\w-]+})|#)?\n*?)/
|
|
138
142
|
.source;
|
|
139
143
|
const ALTERNATE_TITLE = /(?<pattern>\s*(?<title>[^\n]*)\s*\n[=]+)/.source;
|
|
140
144
|
|
|
@@ -152,15 +156,14 @@ export function parseMarkdownContentTitle(
|
|
|
152
156
|
|
|
153
157
|
if (!pattern || !title) {
|
|
154
158
|
return {content, contentTitle: undefined};
|
|
155
|
-
} else {
|
|
156
|
-
const newContent = removeContentTitleOption
|
|
157
|
-
? content.replace(pattern, '')
|
|
158
|
-
: content;
|
|
159
|
-
return {
|
|
160
|
-
content: newContent.trim(),
|
|
161
|
-
contentTitle: toTextContentTitle(title.trim()).trim(),
|
|
162
|
-
};
|
|
163
159
|
}
|
|
160
|
+
const newContent = removeContentTitleOption
|
|
161
|
+
? content.replace(pattern, '')
|
|
162
|
+
: content;
|
|
163
|
+
return {
|
|
164
|
+
content: newContent.trim(),
|
|
165
|
+
contentTitle: toTextContentTitle(title.trim()).trim(),
|
|
166
|
+
};
|
|
164
167
|
}
|
|
165
168
|
|
|
166
169
|
type ParsedMarkdown = {
|
package/src/pathUtils.ts
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
import path from 'path';
|
|
11
11
|
|
|
12
|
-
// MacOS (APFS) and Windows (NTFS) filename length limit = 255 chars,
|
|
12
|
+
// MacOS (APFS) and Windows (NTFS) filename length limit = 255 chars,
|
|
13
|
+
// Others = 255 bytes
|
|
13
14
|
const MAX_PATH_SEGMENT_CHARS = 255;
|
|
14
15
|
const MAX_PATH_SEGMENT_BYTES = 255;
|
|
15
16
|
// Space for appending things to the string like file extensions and so on
|
|
@@ -19,7 +20,7 @@ const isMacOs = () => process.platform === 'darwin';
|
|
|
19
20
|
const isWindows = () => process.platform === 'win32';
|
|
20
21
|
|
|
21
22
|
export const isNameTooLong = (str: string): boolean =>
|
|
22
|
-
//
|
|
23
|
+
// Not entirely correct: we can't assume FS from OS. But good enough?
|
|
23
24
|
isMacOs() || isWindows()
|
|
24
25
|
? str.length + SPACE_FOR_APPENDING > MAX_PATH_SEGMENT_CHARS // MacOS (APFS) and Windows (NTFS) filename length limit (255 chars)
|
|
25
26
|
: Buffer.from(str).length + SPACE_FOR_APPENDING > MAX_PATH_SEGMENT_BYTES; // Other (255 bytes)
|
|
@@ -56,7 +57,8 @@ export const shortName = (str: string): string => {
|
|
|
56
57
|
export function posixPath(str: string): string {
|
|
57
58
|
const isExtendedLengthPath = /^\\\\\?\\/.test(str);
|
|
58
59
|
|
|
59
|
-
// Forward slashes are only valid Windows paths when they don't contain non-
|
|
60
|
+
// Forward slashes are only valid Windows paths when they don't contain non-
|
|
61
|
+
// ascii characters.
|
|
60
62
|
// eslint-disable-next-line no-control-regex
|
|
61
63
|
const hasNonAscii = /[^\u0000-\u0080]+/.test(str);
|
|
62
64
|
|
|
@@ -66,13 +68,18 @@ export function posixPath(str: string): string {
|
|
|
66
68
|
return str.replace(/\\/g, '/');
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
/**
|
|
72
|
+
* When you want to display a path in a message/warning/error, it's more
|
|
73
|
+
* convenient to:
|
|
74
|
+
*
|
|
75
|
+
* - make it relative to `cwd()`
|
|
76
|
+
* - convert to posix (ie not using windows \ path separator)
|
|
77
|
+
*
|
|
78
|
+
* This way, Jest tests can run more reliably on any computer/CI on both
|
|
79
|
+
* Unix/Windows
|
|
80
|
+
* For Windows users this is not perfect (as they see / instead of \) but it's
|
|
81
|
+
* probably good enough
|
|
82
|
+
*/
|
|
76
83
|
export function toMessageRelativeFilePath(filePath: string): string {
|
|
77
84
|
return posixPath(path.relative(process.cwd(), filePath));
|
|
78
85
|
}
|
|
@@ -92,7 +99,8 @@ export function aliasedSitePath(filePath: string, siteDir: string): string {
|
|
|
92
99
|
/**
|
|
93
100
|
* When you have a path like C:\X\Y
|
|
94
101
|
* It is not safe to use directly when generating code
|
|
95
|
-
* For example, this would fail due to unescaped \:
|
|
102
|
+
* For example, this would fail due to unescaped \:
|
|
103
|
+
* `<img src={require('${filePath}')} />`
|
|
96
104
|
* But this would work: `<img src={require('${escapePath(filePath)}')} />`
|
|
97
105
|
*
|
|
98
106
|
* posixPath can't be used in all cases, because forward slashes are only valid
|
package/src/tags.ts
CHANGED
|
@@ -28,9 +28,9 @@ export function normalizeFrontMatterTag(
|
|
|
28
28
|
|
|
29
29
|
// TODO maybe make ensure the permalink is valid url path?
|
|
30
30
|
function normalizeTagPermalink(permalink: string): string {
|
|
31
|
-
// note: we always apply tagsPath on purpose
|
|
32
|
-
//
|
|
33
|
-
// tagsPath is different for each doc version
|
|
31
|
+
// note: we always apply tagsPath on purpose. For versioned docs, v1/doc.md
|
|
32
|
+
// and v2/doc.md tags with custom permalinks don't lead to the same created
|
|
33
|
+
// page. tagsPath is different for each doc version
|
|
34
34
|
return normalizeUrl([tagsPath, permalink]);
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -61,11 +61,14 @@ export type TaggedItemGroup<Item> = {
|
|
|
61
61
|
items: Item[];
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Permits to group docs/blogPosts by tag (provided by front matter)
|
|
66
|
+
* Note: groups are indexed by permalink, because routes must be unique in the
|
|
67
|
+
* end. Labels may vary on 2 md files but they are normalized. Docs with
|
|
68
|
+
* label='some label' and label='some-label' should end-up in the same
|
|
69
|
+
* group/page in the end. We can't create 2 routes /some-label because one would
|
|
70
|
+
* override the other
|
|
71
|
+
*/
|
|
69
72
|
export function groupTaggedItems<Item>(
|
|
70
73
|
items: Item[],
|
|
71
74
|
getItemTags: (item: Item) => Tag[],
|
|
@@ -74,7 +77,8 @@ export function groupTaggedItems<Item>(
|
|
|
74
77
|
|
|
75
78
|
function handleItemTag(item: Item, tag: Tag) {
|
|
76
79
|
// Init missing tag groups
|
|
77
|
-
// TODO: it's not really clear what should be the behavior if 2 items have
|
|
80
|
+
// TODO: it's not really clear what should be the behavior if 2 items have
|
|
81
|
+
// the same tag but the permalink is different for each
|
|
78
82
|
// For now, the first tag found wins
|
|
79
83
|
result[tag.permalink] = result[tag.permalink] ?? {
|
|
80
84
|
tag,
|
package/src/urlUtils.ts
CHANGED
|
@@ -16,7 +16,8 @@ export function normalizeUrl(rawUrls: string[]): string {
|
|
|
16
16
|
if (urls[0].match(/^[^/:]+:\/*$/) && urls.length > 1) {
|
|
17
17
|
const first = urls.shift();
|
|
18
18
|
if (first!.startsWith('file:') && urls[0].startsWith('/')) {
|
|
19
|
-
// Force a double slash here, else we lose the information that the next
|
|
19
|
+
// Force a double slash here, else we lose the information that the next
|
|
20
|
+
// segment is an absolute path
|
|
20
21
|
urls[0] = `${first}//${urls[0]}`;
|
|
21
22
|
} else {
|
|
22
23
|
urls[0] = first + urls[0];
|
|
@@ -26,7 +27,7 @@ export function normalizeUrl(rawUrls: string[]): string {
|
|
|
26
27
|
// There must be two or three slashes in the file protocol,
|
|
27
28
|
// two slashes in anything else.
|
|
28
29
|
const replacement = urls[0].match(/^file:\/\/\//) ? '$1:///' : '$1://';
|
|
29
|
-
urls[0] = urls[0].replace(/^([^/:]+):\/*/, replacement);
|
|
30
|
+
urls[0] = urls[0].replace(/^(?<protocol>[^/:]+):\/*/, replacement);
|
|
30
31
|
|
|
31
32
|
for (let i = 0; i < urls.length; i += 1) {
|
|
32
33
|
let component = urls[i];
|
|
@@ -48,14 +49,15 @@ export function normalizeUrl(rawUrls: string[]): string {
|
|
|
48
49
|
// Removing the starting slashes for each component but the first.
|
|
49
50
|
component = component.replace(
|
|
50
51
|
/^[/]+/,
|
|
51
|
-
// Special case where the first element of rawUrls is empty
|
|
52
|
+
// Special case where the first element of rawUrls is empty
|
|
53
|
+
// ["", "/hello"] => /hello
|
|
52
54
|
component[0] === '/' && !hasStartingSlash ? '/' : '',
|
|
53
55
|
);
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
hasEndingSlash = component[component.length - 1] === '/';
|
|
57
|
-
// Removing the ending slashes for each component but the last.
|
|
58
|
-
//
|
|
59
|
+
// Removing the ending slashes for each component but the last. For the
|
|
60
|
+
// last component we will combine multiple slashes to a single one.
|
|
59
61
|
component = component.replace(/[/]+$/, i < urls.length - 1 ? '' : '/');
|
|
60
62
|
}
|
|
61
63
|
|
|
@@ -68,14 +70,14 @@ export function normalizeUrl(rawUrls: string[]): string {
|
|
|
68
70
|
// except the possible first plain protocol part.
|
|
69
71
|
|
|
70
72
|
// Remove trailing slash before parameters or hash.
|
|
71
|
-
str = str.replace(/\/(
|
|
73
|
+
str = str.replace(/\/(?<search>\?|&|#[^!])/g, '$1');
|
|
72
74
|
|
|
73
75
|
// Replace ? in parameters with &.
|
|
74
76
|
const parts = str.split('?');
|
|
75
77
|
str = parts.shift() + (parts.length > 0 ? '?' : '') + parts.join('&');
|
|
76
78
|
|
|
77
79
|
// Dedupe forward slashes in the entire path, avoiding protocol slashes.
|
|
78
|
-
str = str.replace(/([^:/]\/)\/+/g, '$1');
|
|
80
|
+
str = str.replace(/(?<textBefore>[^:/]\/)\/+/g, '$1');
|
|
79
81
|
|
|
80
82
|
// Dedupe forward slashes at the beginning of the path.
|
|
81
83
|
str = str.replace(/^\/+/g, '/');
|
package/src/webpackUtils.ts
CHANGED
|
@@ -33,7 +33,8 @@ type FileLoaderUtils = {
|
|
|
33
33
|
|
|
34
34
|
// Inspired by https://github.com/gatsbyjs/gatsby/blob/8e6e021014da310b9cc7d02e58c9b3efe938c665/packages/gatsby/src/utils/webpack-utils.ts#L447
|
|
35
35
|
export function getFileLoaderUtils(): FileLoaderUtils {
|
|
36
|
-
// files/images < urlLoaderLimit will be inlined as base64 strings directly in
|
|
36
|
+
// files/images < urlLoaderLimit will be inlined as base64 strings directly in
|
|
37
|
+
// the html
|
|
37
38
|
const urlLoaderLimit = WEBPACK_URL_LOADER_LIMIT;
|
|
38
39
|
|
|
39
40
|
// defines the path/pattern of the assets handled by webpack
|
|
@@ -56,7 +57,7 @@ export function getFileLoaderUtils(): FileLoaderUtils {
|
|
|
56
57
|
},
|
|
57
58
|
}),
|
|
58
59
|
|
|
59
|
-
// TODO
|
|
60
|
+
// TODO avoid conflicts with the ideal-image plugin
|
|
60
61
|
// TODO this may require a little breaking change for ideal-image users?
|
|
61
62
|
// Maybe with the ideal image plugin, all md images should be "ideal"?
|
|
62
63
|
// This is used to force url-loader+file-loader on markdown images
|
|
@@ -78,12 +79,12 @@ export function getFileLoaderUtils(): FileLoaderUtils {
|
|
|
78
79
|
*/
|
|
79
80
|
images: () => ({
|
|
80
81
|
use: [loaders.url({folder: 'images'})],
|
|
81
|
-
test: /\.(ico|
|
|
82
|
+
test: /\.(?:ico|jpe?g|png|gif|webp)(?:\?.*)?$/i,
|
|
82
83
|
}),
|
|
83
84
|
|
|
84
85
|
fonts: () => ({
|
|
85
86
|
use: [loaders.url({folder: 'fonts'})],
|
|
86
|
-
test: /\.(
|
|
87
|
+
test: /\.(?:woff2?|eot|ttf|otf)$/i,
|
|
87
88
|
}),
|
|
88
89
|
|
|
89
90
|
/**
|
|
@@ -92,11 +93,11 @@ export function getFileLoaderUtils(): FileLoaderUtils {
|
|
|
92
93
|
*/
|
|
93
94
|
media: () => ({
|
|
94
95
|
use: [loaders.url({folder: 'medias'})],
|
|
95
|
-
test: /\.(mp4|webm|ogv|wav|mp3|m4a|aac|oga|flac)
|
|
96
|
+
test: /\.(?:mp4|webm|ogv|wav|mp3|m4a|aac|oga|flac)$/i,
|
|
96
97
|
}),
|
|
97
98
|
|
|
98
99
|
svg: () => ({
|
|
99
|
-
test: /\.svg
|
|
100
|
+
test: /\.svg$/i,
|
|
100
101
|
oneOf: [
|
|
101
102
|
{
|
|
102
103
|
use: [
|
|
@@ -125,7 +126,7 @@ export function getFileLoaderUtils(): FileLoaderUtils {
|
|
|
125
126
|
// We don't want to use SVGR loader for non-React source code
|
|
126
127
|
// ie we don't want to use SVGR for CSS files...
|
|
127
128
|
issuer: {
|
|
128
|
-
and: [/\.(
|
|
129
|
+
and: [/\.(?:tsx?|jsx?|mdx?)$/i],
|
|
129
130
|
},
|
|
130
131
|
},
|
|
131
132
|
{
|
|
@@ -136,7 +137,7 @@ export function getFileLoaderUtils(): FileLoaderUtils {
|
|
|
136
137
|
|
|
137
138
|
otherAssets: () => ({
|
|
138
139
|
use: [loaders.file({folder: 'files'})],
|
|
139
|
-
test: /\.(pdf|
|
|
140
|
+
test: /\.(?:pdf|docx?|xlsx?|zip|rar)$/i,
|
|
140
141
|
}),
|
|
141
142
|
};
|
|
142
143
|
|