@docusaurus/utils 2.0.0-beta.138b4c997 → 2.0.0-beta.14
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 +20 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +27 -0
- package/lib/constants.js.map +1 -0
- package/lib/escapePath.d.ts +1 -0
- package/lib/escapePath.d.ts.map +1 -0
- package/lib/escapePath.js +1 -0
- package/lib/escapePath.js.map +1 -0
- package/lib/globUtils.d.ts +12 -0
- package/lib/globUtils.d.ts.map +1 -0
- package/lib/globUtils.js +48 -0
- package/lib/globUtils.js.map +1 -0
- package/lib/hashUtils.d.ts +1 -0
- package/lib/hashUtils.d.ts.map +1 -0
- package/lib/hashUtils.js +5 -4
- package/lib/hashUtils.js.map +1 -0
- package/lib/index.d.ts +11 -7
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +43 -96
- package/lib/index.js.map +1 -0
- package/lib/markdownLinks.d.ts +1 -0
- package/lib/markdownLinks.d.ts.map +1 -0
- package/lib/markdownLinks.js +20 -6
- package/lib/markdownLinks.js.map +1 -0
- package/lib/markdownParser.d.ts +1 -0
- package/lib/markdownParser.d.ts.map +1 -0
- package/lib/markdownParser.js +17 -8
- package/lib/markdownParser.js.map +1 -0
- package/lib/mdxUtils.d.ts +17 -0
- package/lib/mdxUtils.d.ts.map +1 -0
- package/lib/mdxUtils.js +31 -0
- package/lib/mdxUtils.js.map +1 -0
- package/lib/{getFilePathForRoutePath.d.ts → normalizeUrl.d.ts} +2 -1
- package/lib/normalizeUrl.d.ts.map +1 -0
- package/lib/normalizeUrl.js +67 -0
- package/lib/normalizeUrl.js.map +1 -0
- package/lib/pathUtils.d.ts +1 -0
- package/lib/pathUtils.d.ts.map +1 -0
- package/lib/pathUtils.js +4 -5
- package/lib/pathUtils.js.map +1 -0
- package/lib/posixPath.d.ts +1 -0
- package/lib/posixPath.d.ts.map +1 -0
- package/lib/posixPath.js +1 -0
- package/lib/posixPath.js.map +1 -0
- package/lib/slugger.d.ts +14 -0
- package/lib/slugger.d.ts.map +1 -0
- package/lib/slugger.js +19 -0
- package/lib/slugger.js.map +1 -0
- package/lib/tags.d.ts +19 -0
- package/lib/tags.d.ts.map +1 -0
- package/lib/tags.js +73 -0
- package/lib/tags.js.map +1 -0
- package/lib/webpackUtils.d.ts +30 -0
- package/lib/webpackUtils.d.ts.map +1 -0
- package/lib/webpackUtils.js +110 -0
- package/lib/webpackUtils.js.map +1 -0
- package/package.json +25 -8
- package/src/constants.ts +38 -0
- package/src/deps.d.ts +14 -0
- package/src/globUtils.ts +63 -0
- package/src/index.ts +25 -96
- package/src/markdownLinks.ts +19 -8
- package/src/markdownParser.ts +21 -16
- package/src/mdxUtils.ts +32 -0
- package/src/normalizeUrl.ts +80 -0
- package/src/pathUtils.ts +2 -3
- package/src/slugger.ts +24 -0
- package/src/tags.ts +100 -0
- package/src/webpackUtils.ts +144 -0
- package/lib/.tsbuildinfo +0 -1
- package/lib/codeTranslationsUtils.d.ts +0 -11
- package/lib/codeTranslationsUtils.js +0 -50
- package/lib/getFilePathForRoutePath.js +0 -40
- package/src/__tests__/__fixtures__/defaultCodeTranslations/en.json +0 -4
- package/src/__tests__/__fixtures__/defaultCodeTranslations/fr-FR.json +0 -5
- package/src/__tests__/__fixtures__/defaultCodeTranslations/fr.json +0 -4
- package/src/__tests__/__snapshots__/index.test.ts.snap +0 -8
- package/src/__tests__/codeTranslationsUtils.test.ts +0 -112
- package/src/__tests__/escapePath.test.ts +0 -25
- package/src/__tests__/getFilePathForRoutePath.test.ts +0 -87
- package/src/__tests__/hashUtils.test.ts +0 -51
- package/src/__tests__/index.test.ts +0 -631
- package/src/__tests__/markdownParser.test.ts +0 -817
- package/src/__tests__/pathUtils.test.ts +0 -63
- package/src/__tests__/posixPath.test.ts +0 -25
- package/src/codeTranslationsUtils.ts +0 -56
- package/src/getFilePathForRoutePath.ts +0 -43
- package/tsconfig.json +0 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownParser.d.ts","sourceRoot":"","sources":["../src/markdownParser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA8DpE;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;AAYD,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,CAmCrD;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;AAED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IAAC,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAC,GACvC,OAAO,CAAC,cAAc,CAAC,CASzB"}
|
package/lib/markdownParser.js
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.parseMarkdownFile = exports.parseMarkdownString = exports.parseMarkdownContentTitle = exports.parseFrontMatter = exports.createExcerpt = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const
|
|
12
|
-
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
13
|
-
const gray_matter_1 = tslib_1.__importDefault(require("gray-matter"));
|
|
11
|
+
const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
|
|
12
|
+
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
13
|
+
const gray_matter_1 = (0, tslib_1.__importDefault)(require("gray-matter"));
|
|
14
14
|
// Hacky way of stripping out import statements from the excerpt
|
|
15
15
|
// TODO: Find a better way to do so, possibly by compiling the Markdown content,
|
|
16
16
|
// stripping out HTML tags and obtaining the first line.
|
|
@@ -20,6 +20,7 @@ function createExcerpt(fileString) {
|
|
|
20
20
|
// Remove Markdown alternate title
|
|
21
21
|
.replace(/^[^\n]*\n[=]+/g, '')
|
|
22
22
|
.split('\n');
|
|
23
|
+
let inCode = false;
|
|
23
24
|
/* eslint-disable no-continue */
|
|
24
25
|
// eslint-disable-next-line no-restricted-syntax
|
|
25
26
|
for (const fileLine of fileLines) {
|
|
@@ -31,6 +32,14 @@ function createExcerpt(fileString) {
|
|
|
31
32
|
if (/^\s*?import\s.*(from.*)?;?|export\s.*{.*};?/.test(fileLine)) {
|
|
32
33
|
continue;
|
|
33
34
|
}
|
|
35
|
+
// Skip code block line.
|
|
36
|
+
if (fileLine.trim().startsWith('```')) {
|
|
37
|
+
inCode = !inCode;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
else if (inCode) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
34
43
|
const cleanedLine = fileLine
|
|
35
44
|
// Remove HTML tags.
|
|
36
45
|
.replace(/<[^>]*>/g, '')
|
|
@@ -66,7 +75,7 @@ function createExcerpt(fileString) {
|
|
|
66
75
|
exports.createExcerpt = createExcerpt;
|
|
67
76
|
function parseFrontMatter(markdownFileContent) {
|
|
68
77
|
var _a;
|
|
69
|
-
const { data, content } = gray_matter_1.default(markdownFileContent);
|
|
78
|
+
const { data, content } = (0, gray_matter_1.default)(markdownFileContent);
|
|
70
79
|
return {
|
|
71
80
|
frontMatter: data !== null && data !== void 0 ? data : {},
|
|
72
81
|
content: (_a = content === null || content === void 0 ? void 0 : content.trim()) !== null && _a !== void 0 ? _a : '',
|
|
@@ -86,8 +95,7 @@ function parseMarkdownContentTitle(contentUntrimmed, options) {
|
|
|
86
95
|
var _a, _b;
|
|
87
96
|
const removeContentTitleOption = (_a = options === null || options === void 0 ? void 0 : options.removeContentTitle) !== null && _a !== void 0 ? _a : false;
|
|
88
97
|
const content = contentUntrimmed.trim();
|
|
89
|
-
const IMPORT_STATEMENT = /import\s+(([\w*{}\s\n,]+)from\s+)?["'\s]([@\w/_.-]+)["'\s];?|\n
|
|
90
|
-
.source;
|
|
98
|
+
const IMPORT_STATEMENT = /import\s+(([\w*{}\s\n,]+)from\s+)?["'\s]([@\w/_.-]+)["'\s];?|\n/.source;
|
|
91
99
|
const REGULAR_TITLE = /(?<pattern>#\s*(?<title>[^#\n{]*)+[ \t]*(?<suffix>({#*[\w-]+})|#)?\n*?)/
|
|
92
100
|
.source;
|
|
93
101
|
const ALTERNATE_TITLE = /(?<pattern>\s*(?<title>[^\n]*)\s*\n[=]+)/.source;
|
|
@@ -122,8 +130,8 @@ function parseMarkdownString(markdownFileContent, options) {
|
|
|
122
130
|
};
|
|
123
131
|
}
|
|
124
132
|
catch (e) {
|
|
125
|
-
|
|
126
|
-
This can happen if you use special characters in frontmatter values (try using double quotes around that value).`)
|
|
133
|
+
logger_1.default.error(`Error while parsing Markdown frontmatter.
|
|
134
|
+
This can happen if you use special characters in frontmatter values (try using double quotes around that value).`);
|
|
127
135
|
throw e;
|
|
128
136
|
}
|
|
129
137
|
}
|
|
@@ -138,3 +146,4 @@ async function parseMarkdownFile(source, options) {
|
|
|
138
146
|
}
|
|
139
147
|
}
|
|
140
148
|
exports.parseMarkdownFile = parseMarkdownFile;
|
|
149
|
+
//# sourceMappingURL=markdownParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownParser.js","sourceRoot":"","sources":["../src/markdownParser.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,6EAAwC;AACxC,qEAA0B;AAC1B,2EAAiC;AAEjC,gEAAgE;AAChE,gFAAgF;AAChF,wDAAwD;AACxD,SAAgB,aAAa,CAAC,UAAkB;IAC9C,MAAM,SAAS,GAAG,UAAU;SACzB,QAAQ,EAAE;QACX,kCAAkC;SACjC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC;SAC7B,KAAK,CAAC,IAAI,CAAC,CAAC;IACf,IAAI,MAAM,GAAG,KAAK,CAAC;IAEnB,gCAAgC;IAChC,gDAAgD;IAChD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,mBAAmB;QACnB,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE;YACpB,SAAS;SACV;QAED,kCAAkC;QAClC,IAAI,6CAA6C,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;YAChE,SAAS;SACV;QAED,wBAAwB;QACxB,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;YACrC,MAAM,GAAG,CAAC,MAAM,CAAC;YACjB,SAAS;SACV;aAAM,IAAI,MAAM,EAAE;YACjB,SAAS;SACV;QAED,MAAM,WAAW,GAAG,QAAQ;YAC1B,oBAAoB;aACnB,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;YACxB,uBAAuB;aACtB,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC;YACnC,sCAAsC;aACrC,OAAO,CAAC,iCAAiC,EAAE,IAAI,CAAC;YACjD,sCAAsC;aACrC,OAAO,CAAC,+BAA+B,EAAE,IAAI,CAAC;YAC/C,iBAAiB;aAChB,OAAO,CAAC,yBAAyB,EAAE,IAAI,CAAC;YACzC,oBAAoB;aACnB,OAAO,C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,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;iHACgG,CAAC,CAAC;QAC/G,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AA1BD,kDA0BC;AAEM,KAAK,UAAU,iBAAiB,CACrC,MAAc,EACd,OAAwC;IAExC,MAAM,cAAc,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1D,IAAI;QACF,OAAO,mBAAmB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;KACrD;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CACb,qCAAqC,MAAM,MAAO,CAAW,CAAC,OAAO,IAAI,CAC1E,CAAC;KACH;AACH,CAAC;AAZD,8CAYC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
* Transform mdx text to plain html text
|
|
9
|
+
* Initially created to convert MDX blog posts to HTML for the RSS feed
|
|
10
|
+
* without import/export nodes
|
|
11
|
+
*
|
|
12
|
+
* TODO not ideal implementation, won't work well with MDX elements!
|
|
13
|
+
* TODO theme+global site config should be able to declare MDX comps in scope for rendering the RSS feeds
|
|
14
|
+
* see also https://github.com/facebook/docusaurus/issues/4625
|
|
15
|
+
*/
|
|
16
|
+
export declare function mdxToHtml(mdxStr: string): string;
|
|
17
|
+
//# sourceMappingURL=mdxUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdxUtils.d.ts","sourceRoot":"","sources":["../src/mdxUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,GAEb,MAAM,CAMR"}
|
package/lib/mdxUtils.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.mdxToHtml = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const react_1 = (0, tslib_1.__importDefault)(require("react"));
|
|
12
|
+
const server_1 = (0, tslib_1.__importDefault)(require("react-dom/server"));
|
|
13
|
+
const runtime_1 = (0, tslib_1.__importDefault)(require("@mdx-js/runtime"));
|
|
14
|
+
const remark_mdx_remove_imports_1 = (0, tslib_1.__importDefault)(require("remark-mdx-remove-imports"));
|
|
15
|
+
const remark_mdx_remove_exports_1 = (0, tslib_1.__importDefault)(require("remark-mdx-remove-exports"));
|
|
16
|
+
/**
|
|
17
|
+
* Transform mdx text to plain html text
|
|
18
|
+
* Initially created to convert MDX blog posts to HTML for the RSS feed
|
|
19
|
+
* without import/export nodes
|
|
20
|
+
*
|
|
21
|
+
* TODO not ideal implementation, won't work well with MDX elements!
|
|
22
|
+
* TODO theme+global site config should be able to declare MDX comps in scope for rendering the RSS feeds
|
|
23
|
+
* see also https://github.com/facebook/docusaurus/issues/4625
|
|
24
|
+
*/
|
|
25
|
+
function mdxToHtml(mdxStr) {
|
|
26
|
+
return server_1.default.renderToString(react_1.default.createElement(runtime_1.default, { remarkPlugins: [remark_mdx_remove_imports_1.default, remark_mdx_remove_exports_1.default] }, [
|
|
27
|
+
mdxStr,
|
|
28
|
+
]));
|
|
29
|
+
}
|
|
30
|
+
exports.mdxToHtml = mdxToHtml;
|
|
31
|
+
//# sourceMappingURL=mdxUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdxUtils.js","sourceRoot":"","sources":["../src/mdxUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,+DAA0B;AAC1B,2EAA8C;AAC9C,2EAAkC;AAClC,uGAAsD;AACtD,uGAAsD;AAEtD;;;;;;;;GAQG;AACH,SAAgB,SAAS,CACvB,MAAc;IAGd,OAAO,gBAAc,CAAC,cAAc,CAClC,eAAK,CAAC,aAAa,CAAC,iBAAG,EAAE,EAAC,aAAa,EAAE,CAAC,mCAAa,EAAE,mCAAa,CAAC,EAAC,EAAE;QACxE,MAAM;KACP,CAAC,CACH,CAAC;AACJ,CAAC;AATD,8BASC"}
|
|
@@ -4,4 +4,5 @@
|
|
|
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 declare function
|
|
7
|
+
export declare function normalizeUrl(rawUrls: string[]): string;
|
|
8
|
+
//# sourceMappingURL=normalizeUrl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeUrl.d.ts","sourceRoot":"","sources":["../src/normalizeUrl.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAwEtD"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.normalizeUrl = void 0;
|
|
10
|
+
function normalizeUrl(rawUrls) {
|
|
11
|
+
const urls = [...rawUrls];
|
|
12
|
+
const resultArray = [];
|
|
13
|
+
let hasStartingSlash = false;
|
|
14
|
+
let hasEndingSlash = false;
|
|
15
|
+
// If the first part is a plain protocol, we combine it with the next part.
|
|
16
|
+
if (urls[0].match(/^[^/:]+:\/*$/) && urls.length > 1) {
|
|
17
|
+
const first = urls.shift();
|
|
18
|
+
urls[0] = first + urls[0];
|
|
19
|
+
}
|
|
20
|
+
// There must be two or three slashes in the file protocol,
|
|
21
|
+
// two slashes in anything else.
|
|
22
|
+
const replacement = urls[0].match(/^file:\/\/\//) ? '$1:///' : '$1://';
|
|
23
|
+
urls[0] = urls[0].replace(/^([^/:]+):\/*/, replacement);
|
|
24
|
+
// eslint-disable-next-line
|
|
25
|
+
for (let i = 0; i < urls.length; i++) {
|
|
26
|
+
let component = urls[i];
|
|
27
|
+
if (typeof component !== 'string') {
|
|
28
|
+
throw new TypeError(`Url must be a string. Received ${typeof component}`);
|
|
29
|
+
}
|
|
30
|
+
if (component === '') {
|
|
31
|
+
if (i === urls.length - 1 && hasEndingSlash) {
|
|
32
|
+
resultArray.push('/');
|
|
33
|
+
}
|
|
34
|
+
// eslint-disable-next-line
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (component !== '/') {
|
|
38
|
+
if (i > 0) {
|
|
39
|
+
// Removing the starting slashes for each component but the first.
|
|
40
|
+
component = component.replace(/^[/]+/,
|
|
41
|
+
// Special case where the first element of rawUrls is empty ["", "/hello"] => /hello
|
|
42
|
+
component[0] === '/' && !hasStartingSlash ? '/' : '');
|
|
43
|
+
}
|
|
44
|
+
hasEndingSlash = component[component.length - 1] === '/';
|
|
45
|
+
// Removing the ending slashes for each component but the last.
|
|
46
|
+
// For the last component we will combine multiple slashes to a single one.
|
|
47
|
+
component = component.replace(/[/]+$/, i < urls.length - 1 ? '' : '/');
|
|
48
|
+
}
|
|
49
|
+
hasStartingSlash = true;
|
|
50
|
+
resultArray.push(component);
|
|
51
|
+
}
|
|
52
|
+
let str = resultArray.join('/');
|
|
53
|
+
// Each input component is now separated by a single slash
|
|
54
|
+
// except the possible first plain protocol part.
|
|
55
|
+
// Remove trailing slash before parameters or hash.
|
|
56
|
+
str = str.replace(/\/(\?|&|#[^!])/g, '$1');
|
|
57
|
+
// Replace ? in parameters with &.
|
|
58
|
+
const parts = str.split('?');
|
|
59
|
+
str = parts.shift() + (parts.length > 0 ? '?' : '') + parts.join('&');
|
|
60
|
+
// Dedupe forward slashes in the entire path, avoiding protocol slashes.
|
|
61
|
+
str = str.replace(/([^:]\/)\/+/g, '$1');
|
|
62
|
+
// Dedupe forward slashes at the beginning of the path.
|
|
63
|
+
str = str.replace(/^\/+/g, '/');
|
|
64
|
+
return str;
|
|
65
|
+
}
|
|
66
|
+
exports.normalizeUrl = normalizeUrl;
|
|
67
|
+
//# sourceMappingURL=normalizeUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeUrl.js","sourceRoot":"","sources":["../src/normalizeUrl.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,K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ANGED
|
@@ -15,11 +15,9 @@ const MAX_PATH_SEGMENT_BYTES = 255;
|
|
|
15
15
|
const SPACE_FOR_APPENDING = 10;
|
|
16
16
|
const isMacOs = process.platform === `darwin`;
|
|
17
17
|
const isWindows = process.platform === `win32`;
|
|
18
|
-
const isNameTooLong = (str) =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
: Buffer.from(str).length + SPACE_FOR_APPENDING > MAX_PATH_SEGMENT_BYTES; // Other (255 bytes)
|
|
22
|
-
};
|
|
18
|
+
const isNameTooLong = (str) => isMacOs || isWindows
|
|
19
|
+
? str.length + SPACE_FOR_APPENDING > MAX_PATH_SEGMENT_CHARS // MacOS (APFS) and Windows (NTFS) filename length limit (255 chars)
|
|
20
|
+
: Buffer.from(str).length + SPACE_FOR_APPENDING > MAX_PATH_SEGMENT_BYTES; // Other (255 bytes)
|
|
23
21
|
exports.isNameTooLong = isNameTooLong;
|
|
24
22
|
const shortName = (str) => {
|
|
25
23
|
if (isMacOs || isWindows) {
|
|
@@ -33,3 +31,4 @@ const shortName = (str) => {
|
|
|
33
31
|
.toString();
|
|
34
32
|
};
|
|
35
33
|
exports.shortName = shortName;
|
|
34
|
+
//# sourceMappingURL=pathUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathUtils.js","sourceRoot":"","sources":["../src/pathUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+DAA+D;AAE/D,wFAAwF;AACxF,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,0EAA0E;AAC1E,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC;AAC9C,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;AAExC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAW,EAAE,CACpD,OAAO,IAAI,SAAS;IAClB,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,mBAAmB,GAAG,sBAAsB,CAAC,oEAAoE;IAChI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,mBAAmB,GAAG,sBAAsB,CAAC,CAAC,oBAAoB;AAHrF,QAAA,aAAa,iBAGmD;AAEtE,MAAM,SAAS,GAAG,CAAC,GAAW,EAAU,EAAE;IAC/C,IAAI,OAAO,IAAI,SAAS,EAAE;QACxB,MAAM,gBAAgB,GAAG,GAAG,CAAC,MAAM,GAAG,sBAAsB,CAAC;QAC7D,OAAO,GAAG,CAAC,KAAK,CACd,CAAC,EACD,GAAG,CAAC,MAAM,GAAG,gBAAgB,GAAG,mBAAmB,GAAG,CAAC,CACxD,CAAC;KACH;IACD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,gBAAgB,GACpB,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,sBAAsB,CAAC;IACxD,OAAO,SAAS;SACb,KAAK,CACJ,CAAC,EACD,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,gBAAgB,GAAG,mBAAmB,GAAG,CAAC,CAC1E;SACA,QAAQ,EAAE,CAAC;AAChB,CAAC,CAAC;AAjBW,QAAA,SAAS,aAiBpB"}
|
package/lib/posixPath.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posixPath.d.ts","sourceRoot":"","sources":["../src/posixPath.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAY7C"}
|
package/lib/posixPath.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"posixPath.js","sourceRoot":"","sources":["../src/posixPath.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,GAAW;IACnC,MAAM,oBAAoB,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEnD,iCAAiC;IACjC,2EAA2E;IAC3E,gFAAgF;IAChF,MAAM,WAAW,GAAG,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,sBAAsB;IAEzE,IAAI,oBAAoB,IAAI,WAAW,EAAE;QACvC,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC;AAZD,8BAYC"}
|
package/lib/slugger.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
export declare type SluggerOptions = {
|
|
8
|
+
maintainCase?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare type Slugger = {
|
|
11
|
+
slug: (value: string, options?: SluggerOptions) => string;
|
|
12
|
+
};
|
|
13
|
+
export declare function createSlugger(): Slugger;
|
|
14
|
+
//# sourceMappingURL=slugger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slugger.d.ts","sourceRoot":"","sources":["../src/slugger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,oBAAY,cAAc,GAAG;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAC,CAAC;AAEtD,oBAAY,OAAO,GAAG;IACpB,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,KAAK,MAAM,CAAC;CAC3D,CAAC;AAEF,wBAAgB,aAAa,IAAI,OAAO,CAKvC"}
|
package/lib/slugger.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createSlugger = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const github_slugger_1 = (0, tslib_1.__importDefault)(require("github-slugger"));
|
|
12
|
+
function createSlugger() {
|
|
13
|
+
const githubSlugger = new github_slugger_1.default();
|
|
14
|
+
return {
|
|
15
|
+
slug: (value, options) => githubSlugger.slug(value, options === null || options === void 0 ? void 0 : options.maintainCase),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.createSlugger = createSlugger;
|
|
19
|
+
//# sourceMappingURL=slugger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slugger.js","sourceRoot":"","sources":["../src/slugger.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,iFAA2C;AAW3C,SAAgB,aAAa;IAC3B,MAAM,aAAa,GAAG,IAAI,wBAAa,EAAE,CAAC;IAC1C,OAAO;QACL,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,CAAC;KAC3E,CAAC;AACJ,CAAC;AALD,sCAKC"}
|
package/lib/tags.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
export declare type Tag = {
|
|
8
|
+
label: string;
|
|
9
|
+
permalink: string;
|
|
10
|
+
};
|
|
11
|
+
export declare type FrontMatterTag = string | Tag;
|
|
12
|
+
export declare function normalizeFrontMatterTag(tagsPath: string, frontMatterTag: FrontMatterTag): Tag;
|
|
13
|
+
export declare function normalizeFrontMatterTags(tagsPath: string, frontMatterTags: FrontMatterTag[] | undefined): Tag[];
|
|
14
|
+
export declare type TaggedItemGroup<Item> = {
|
|
15
|
+
tag: Tag;
|
|
16
|
+
items: Item[];
|
|
17
|
+
};
|
|
18
|
+
export declare function groupTaggedItems<Item>(items: Item[], getItemTags: (item: Item) => Tag[]): Record<string, TaggedItemGroup<Item>>;
|
|
19
|
+
//# sourceMappingURL=tags.d.ts.map
|
|
@@ -0,0 +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,EAAE,cAAc,EAAE,GAAG,SAAS,GAC5C,GAAG,EAAE,CAKP;AAED,oBAAY,eAAe,CAAC,IAAI,IAAI;IAClC,GAAG,EAAE,GAAG,CAAC;IACT,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;AAOF,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,CA6BvC"}
|
package/lib/tags.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.groupTaggedItems = exports.normalizeFrontMatterTags = exports.normalizeFrontMatterTag = void 0;
|
|
10
|
+
const lodash_1 = require("lodash");
|
|
11
|
+
const normalizeUrl_1 = require("./normalizeUrl");
|
|
12
|
+
function normalizeFrontMatterTag(tagsPath, frontMatterTag) {
|
|
13
|
+
function toTagObject(tagString) {
|
|
14
|
+
return {
|
|
15
|
+
label: tagString,
|
|
16
|
+
permalink: (0, lodash_1.kebabCase)(tagString),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
// TODO maybe make ensure the permalink is valid url path?
|
|
20
|
+
function normalizeTagPermalink(permalink) {
|
|
21
|
+
// note: we always apply tagsPath on purpose
|
|
22
|
+
// for versioned docs, v1/doc.md and v2/doc.md tags with custom permalinks don't lead to the same created page
|
|
23
|
+
// tagsPath is different for each doc version
|
|
24
|
+
return (0, normalizeUrl_1.normalizeUrl)([tagsPath, permalink]);
|
|
25
|
+
}
|
|
26
|
+
const tag = typeof frontMatterTag === 'string'
|
|
27
|
+
? toTagObject(frontMatterTag)
|
|
28
|
+
: frontMatterTag;
|
|
29
|
+
return {
|
|
30
|
+
label: tag.label,
|
|
31
|
+
permalink: normalizeTagPermalink(tag.permalink),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
exports.normalizeFrontMatterTag = normalizeFrontMatterTag;
|
|
35
|
+
function normalizeFrontMatterTags(tagsPath, frontMatterTags) {
|
|
36
|
+
var _a;
|
|
37
|
+
const tags = (_a = frontMatterTags === null || frontMatterTags === void 0 ? void 0 : frontMatterTags.map((tag) => normalizeFrontMatterTag(tagsPath, tag))) !== null && _a !== void 0 ? _a : [];
|
|
38
|
+
return (0, lodash_1.uniqBy)(tags, (tag) => tag.permalink);
|
|
39
|
+
}
|
|
40
|
+
exports.normalizeFrontMatterTags = normalizeFrontMatterTags;
|
|
41
|
+
// Permits to group docs/blogPosts by tag (provided by FrontMatter)
|
|
42
|
+
// Note: groups are indexed by permalink, because routes must be unique in the end
|
|
43
|
+
// Labels may vary on 2 md files but they are normalized.
|
|
44
|
+
// Docs with label='some label' and label='some-label' should end-up in the same group/page in the end
|
|
45
|
+
// We can't create 2 routes /some-label because one would override the other
|
|
46
|
+
function groupTaggedItems(items, getItemTags) {
|
|
47
|
+
const result = {};
|
|
48
|
+
function handleItemTag(item, tag) {
|
|
49
|
+
var _a;
|
|
50
|
+
// Init missing tag groups
|
|
51
|
+
// TODO: it's not really clear what should be the behavior if 2 items have the same tag but the permalink is different for each
|
|
52
|
+
// For now, the first tag found wins
|
|
53
|
+
result[tag.permalink] = (_a = result[tag.permalink]) !== null && _a !== void 0 ? _a : {
|
|
54
|
+
tag,
|
|
55
|
+
items: [],
|
|
56
|
+
};
|
|
57
|
+
// Add item to group
|
|
58
|
+
result[tag.permalink].items.push(item);
|
|
59
|
+
}
|
|
60
|
+
items.forEach((item) => {
|
|
61
|
+
getItemTags(item).forEach((tag) => {
|
|
62
|
+
handleItemTag(item, tag);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
// If user add twice the same tag to a md doc (weird but possible),
|
|
66
|
+
// we don't want the item to appear twice in the list...
|
|
67
|
+
Object.values(result).forEach((group) => {
|
|
68
|
+
group.items = (0, lodash_1.uniq)(group.items);
|
|
69
|
+
});
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
exports.groupTaggedItems = groupTaggedItems;
|
|
73
|
+
//# sourceMappingURL=tags.js.map
|
package/lib/tags.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings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AE,GAAQ;;QACzC,0BAA0B;QAC1B,+HAA+H;QAC/H,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;AAhCD,4CAgCC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
import type { RuleSetRule } from 'webpack';
|
|
8
|
+
declare type AssetFolder = 'images' | 'files' | 'fonts' | 'medias';
|
|
9
|
+
declare type FileLoaderUtils = {
|
|
10
|
+
loaders: {
|
|
11
|
+
file: (options: {
|
|
12
|
+
folder: AssetFolder;
|
|
13
|
+
}) => RuleSetRule;
|
|
14
|
+
url: (options: {
|
|
15
|
+
folder: AssetFolder;
|
|
16
|
+
}) => RuleSetRule;
|
|
17
|
+
inlineMarkdownImageFileLoader: string;
|
|
18
|
+
inlineMarkdownLinkFileLoader: string;
|
|
19
|
+
};
|
|
20
|
+
rules: {
|
|
21
|
+
images: () => RuleSetRule;
|
|
22
|
+
fonts: () => RuleSetRule;
|
|
23
|
+
media: () => RuleSetRule;
|
|
24
|
+
svg: () => RuleSetRule;
|
|
25
|
+
otherAssets: () => RuleSetRule;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare function getFileLoaderUtils(): FileLoaderUtils;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=webpackUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,CA6GpD"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getFileLoaderUtils = void 0;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
12
|
+
const posixPath_1 = require("./posixPath");
|
|
13
|
+
const constants_1 = require("./constants");
|
|
14
|
+
// Inspired by https://github.com/gatsbyjs/gatsby/blob/8e6e021014da310b9cc7d02e58c9b3efe938c665/packages/gatsby/src/utils/webpack-utils.ts#L447
|
|
15
|
+
function getFileLoaderUtils() {
|
|
16
|
+
// files/images < urlLoaderLimit will be inlined as base64 strings directly in the html
|
|
17
|
+
const urlLoaderLimit = constants_1.WEBPACK_URL_LOADER_LIMIT;
|
|
18
|
+
// defines the path/pattern of the assets handled by webpack
|
|
19
|
+
const fileLoaderFileName = (folder) => `${constants_1.OUTPUT_STATIC_ASSETS_DIR_NAME}/${folder}/[name]-[hash].[ext]`;
|
|
20
|
+
const loaders = {
|
|
21
|
+
file: (options) => ({
|
|
22
|
+
loader: require.resolve(`file-loader`),
|
|
23
|
+
options: {
|
|
24
|
+
name: fileLoaderFileName(options.folder),
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
url: (options) => ({
|
|
28
|
+
loader: require.resolve('url-loader'),
|
|
29
|
+
options: {
|
|
30
|
+
limit: urlLoaderLimit,
|
|
31
|
+
name: fileLoaderFileName(options.folder),
|
|
32
|
+
fallback: require.resolve('file-loader'),
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
// TODO find a better solution to avoid conflicts with the ideal-image plugin
|
|
36
|
+
// TODO this may require a little breaking change for ideal-image users?
|
|
37
|
+
// Maybe with the ideal image plugin, all md images should be "ideal"?
|
|
38
|
+
// This is used to force url-loader+file-loader on markdown images
|
|
39
|
+
// https://webpack.js.org/concepts/loaders/#inline
|
|
40
|
+
inlineMarkdownImageFileLoader: `!${(0, posixPath_1.posixPath)(require.resolve('url-loader'))}?limit=${urlLoaderLimit}&name=${fileLoaderFileName('images')}&fallback=${(0, posixPath_1.posixPath)(require.resolve('file-loader'))}!`,
|
|
41
|
+
inlineMarkdownLinkFileLoader: `!${(0, posixPath_1.posixPath)(require.resolve('file-loader'))}?name=${fileLoaderFileName('files')}!`,
|
|
42
|
+
};
|
|
43
|
+
const rules = {
|
|
44
|
+
/**
|
|
45
|
+
* Loads image assets, inlines images via a data URI if they are below
|
|
46
|
+
* the size threshold
|
|
47
|
+
*/
|
|
48
|
+
images: () => ({
|
|
49
|
+
use: [loaders.url({ folder: 'images' })],
|
|
50
|
+
test: /\.(ico|jpg|jpeg|png|gif|webp)(\?.*)?$/,
|
|
51
|
+
}),
|
|
52
|
+
fonts: () => ({
|
|
53
|
+
use: [loaders.url({ folder: 'fonts' })],
|
|
54
|
+
test: /\.(woff|woff2|eot|ttf|otf)$/,
|
|
55
|
+
}),
|
|
56
|
+
/**
|
|
57
|
+
* Loads audio and video and inlines them via a data URI if they are below
|
|
58
|
+
* the size threshold
|
|
59
|
+
*/
|
|
60
|
+
media: () => ({
|
|
61
|
+
use: [loaders.url({ folder: 'medias' })],
|
|
62
|
+
test: /\.(mp4|webm|ogv|wav|mp3|m4a|aac|oga|flac)$/,
|
|
63
|
+
}),
|
|
64
|
+
svg: () => ({
|
|
65
|
+
test: /\.svg?$/,
|
|
66
|
+
oneOf: [
|
|
67
|
+
{
|
|
68
|
+
use: [
|
|
69
|
+
{
|
|
70
|
+
loader: require.resolve('@svgr/webpack'),
|
|
71
|
+
options: {
|
|
72
|
+
prettier: false,
|
|
73
|
+
svgo: true,
|
|
74
|
+
svgoConfig: {
|
|
75
|
+
plugins: [
|
|
76
|
+
{
|
|
77
|
+
name: 'preset-default',
|
|
78
|
+
params: {
|
|
79
|
+
overrides: {
|
|
80
|
+
removeViewBox: false,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
titleProp: true,
|
|
87
|
+
ref: ![path_1.default],
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
// We don't want to use SVGR loader for non-React source code
|
|
92
|
+
// ie we don't want to use SVGR for CSS files...
|
|
93
|
+
issuer: {
|
|
94
|
+
and: [/\.(ts|tsx|js|jsx|md|mdx)$/],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
use: [loaders.url({ folder: 'images' })],
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
}),
|
|
102
|
+
otherAssets: () => ({
|
|
103
|
+
use: [loaders.file({ folder: 'files' })],
|
|
104
|
+
test: /\.(pdf|doc|docx|xls|xlsx|zip|rar)$/,
|
|
105
|
+
}),
|
|
106
|
+
};
|
|
107
|
+
return { loaders, rules };
|
|
108
|
+
}
|
|
109
|
+
exports.getFileLoaderUtils = getFileLoaderUtils;
|
|
110
|
+
//# sourceMappingURL=webpackUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpackUtils.js","sourceRoot":"","sources":["../src/webpackUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAGH,6DAAwB;AACxB,2CAAsC;AACtC,2CAGqB;AAoBrB,+IAA+I;AAC/I,SAAgB,kBAAkB;IAChC,uFAAuF;IACvF,MAAM,cAAc,GAAG,oCAAwB,CAAC;IAEhD,4DAA4D;IAC5D,MAAM,kBAAkB,GAAG,CAAC,MAAmB,EAAE,EAAE,CACjD,GAAG,yCAA6B,IAAI,MAAM,sBAAsB,CAAC;IAEnE,MAAM,OAAO,GAA+B;QAC1C,IAAI,EAAE,CAAC,OAA8B,EAA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