@docusaurus/utils 2.0.0-beta.15d451942 → 2.0.0-beta.18

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.
Files changed (106) hide show
  1. package/README.md +1 -1
  2. package/lib/constants.d.ts +68 -0
  3. package/lib/constants.d.ts.map +1 -0
  4. package/lib/constants.js +71 -0
  5. package/lib/constants.js.map +1 -0
  6. package/lib/dataFileUtils.d.ts +60 -0
  7. package/lib/dataFileUtils.d.ts.map +1 -0
  8. package/lib/dataFileUtils.js +91 -0
  9. package/lib/dataFileUtils.js.map +1 -0
  10. package/lib/emitUtils.d.ts +35 -0
  11. package/lib/emitUtils.d.ts.map +1 -0
  12. package/lib/emitUtils.js +107 -0
  13. package/lib/emitUtils.js.map +1 -0
  14. package/lib/gitUtils.d.ts +66 -0
  15. package/lib/gitUtils.d.ts.map +1 -0
  16. package/lib/gitUtils.js +66 -0
  17. package/lib/gitUtils.js.map +1 -0
  18. package/lib/globUtils.d.ts +39 -0
  19. package/lib/globUtils.d.ts.map +1 -0
  20. package/lib/globUtils.js +66 -0
  21. package/lib/globUtils.js.map +1 -0
  22. package/lib/hashUtils.d.ts +17 -0
  23. package/lib/hashUtils.d.ts.map +1 -0
  24. package/lib/hashUtils.js +42 -0
  25. package/lib/hashUtils.js.map +1 -0
  26. package/lib/i18nUtils.d.ts +28 -0
  27. package/lib/i18nUtils.d.ts.map +1 -0
  28. package/lib/i18nUtils.js +49 -0
  29. package/lib/i18nUtils.js.map +1 -0
  30. package/lib/index.d.ts +16 -82
  31. package/lib/index.d.ts.map +1 -0
  32. package/lib/index.js +89 -411
  33. package/lib/index.js.map +1 -0
  34. package/lib/jsUtils.d.ts +45 -0
  35. package/lib/jsUtils.d.ts.map +1 -0
  36. package/lib/jsUtils.js +94 -0
  37. package/lib/jsUtils.js.map +1 -0
  38. package/lib/markdownLinks.d.ts +49 -5
  39. package/lib/markdownLinks.d.ts.map +1 -0
  40. package/lib/markdownLinks.js +48 -13
  41. package/lib/markdownLinks.js.map +1 -0
  42. package/lib/markdownUtils.d.ts +112 -0
  43. package/lib/markdownUtils.d.ts.map +1 -0
  44. package/lib/markdownUtils.js +271 -0
  45. package/lib/markdownUtils.js.map +1 -0
  46. package/lib/pathUtils.d.ts +52 -0
  47. package/lib/pathUtils.d.ts.map +1 -0
  48. package/lib/pathUtils.js +113 -0
  49. package/lib/pathUtils.js.map +1 -0
  50. package/lib/slugger.d.ts +24 -0
  51. package/lib/slugger.d.ts.map +1 -0
  52. package/lib/slugger.js +23 -0
  53. package/lib/slugger.js.map +1 -0
  54. package/lib/tags.d.ts +48 -0
  55. package/lib/tags.d.ts.map +1 -0
  56. package/lib/tags.js +91 -0
  57. package/lib/tags.js.map +1 -0
  58. package/lib/urlUtils.d.ts +66 -0
  59. package/lib/urlUtils.d.ts.map +1 -0
  60. package/lib/urlUtils.js +208 -0
  61. package/lib/urlUtils.js.map +1 -0
  62. package/lib/webpackUtils.d.ts +35 -0
  63. package/lib/webpackUtils.d.ts.map +1 -0
  64. package/lib/webpackUtils.js +116 -0
  65. package/lib/webpackUtils.js.map +1 -0
  66. package/package.json +20 -10
  67. package/src/constants.ts +90 -0
  68. package/src/dataFileUtils.ts +122 -0
  69. package/src/deps.d.ts +10 -0
  70. package/src/emitUtils.ts +130 -0
  71. package/src/gitUtils.ts +153 -0
  72. package/src/globUtils.ts +80 -0
  73. package/src/hashUtils.ts +38 -0
  74. package/src/i18nUtils.ts +67 -0
  75. package/src/index.ts +94 -521
  76. package/src/jsUtils.ts +102 -0
  77. package/src/markdownLinks.ts +89 -30
  78. package/src/markdownUtils.ts +354 -0
  79. package/src/pathUtils.ts +121 -0
  80. package/src/slugger.ts +36 -0
  81. package/src/tags.ts +117 -0
  82. package/src/urlUtils.ts +235 -0
  83. package/src/webpackUtils.ts +154 -0
  84. package/lib/.tsbuildinfo +0 -3972
  85. package/lib/codeTranslationsUtils.d.ts +0 -11
  86. package/lib/codeTranslationsUtils.js +0 -50
  87. package/lib/escapePath.d.ts +0 -17
  88. package/lib/escapePath.js +0 -25
  89. package/lib/markdownParser.d.ts +0 -28
  90. package/lib/markdownParser.js +0 -132
  91. package/lib/posixPath.d.ts +0 -14
  92. package/lib/posixPath.js +0 -28
  93. package/src/__tests__/__fixtures__/defaultCodeTranslations/en.json +0 -4
  94. package/src/__tests__/__fixtures__/defaultCodeTranslations/fr-FR.json +0 -5
  95. package/src/__tests__/__fixtures__/defaultCodeTranslations/fr.json +0 -4
  96. package/src/__tests__/__snapshots__/index.test.ts.snap +0 -8
  97. package/src/__tests__/codeTranslationsUtils.test.ts +0 -112
  98. package/src/__tests__/escapePath.test.ts +0 -25
  99. package/src/__tests__/index.test.ts +0 -681
  100. package/src/__tests__/markdownParser.test.ts +0 -772
  101. package/src/__tests__/posixPath.test.ts +0 -25
  102. package/src/codeTranslationsUtils.ts +0 -56
  103. package/src/escapePath.ts +0 -23
  104. package/src/markdownParser.ts +0 -177
  105. package/src/posixPath.ts +0 -27
  106. package/tsconfig.json +0 -9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdownUtils.js","sourceRoot":"","sources":["../src/markdownUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,wEAAwC;AACxC,sEAAiC;AACjC,uCAA2E;AAE3E,6EAA6E;AAC7E,6EAA6E;AAC7E,qEAAqE;AAErE;;;;;;GAMG;AACH,SAAgB,sBAAsB,CAAC,OAAe;IAQpD,MAAM,oBAAoB,GAAG,wBAAwB,CAAC;IACtD,MAAM,OAAO,GAAG,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnD,IAAI,OAAO,EAAE;QACX,OAAO;YACL,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAE,EAAE,EAAE,CAAC;YACtC,EAAE,EAAE,OAAO,CAAC,MAAO,CAAC,EAAG;SACxB,CAAC;KACH;IACD,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,EAAE,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G,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAEnD,wCAAwC;QACxC,IAAI,aAAa,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE;YAClC,OAAO,IAAI,CAAC;SACb;QACD,OAAO,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IACjE,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAvCD,wDAuCC"}
@@ -0,0 +1,52 @@
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 const isNameTooLong: (str: string) => boolean;
8
+ export declare function shortName(str: string): string;
9
+ /**
10
+ * Convert Windows backslash paths to posix style paths.
11
+ * E.g: endi\lie -> endi/lie
12
+ *
13
+ * Returns original path if the posix counterpart is not valid Windows path.
14
+ * This makes the legacy code that uses posixPath safe; but also makes it less
15
+ * useful when you actually want a path with forward slashes (e.g. for URL)
16
+ *
17
+ * Adopted from https://github.com/sindresorhus/slash/blob/main/index.js
18
+ */
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
+ */
32
+ export declare function toMessageRelativeFilePath(filePath: string): string;
33
+ /**
34
+ * Alias filepath relative to site directory, very useful so that we
35
+ * don't expose user's site structure.
36
+ * Example: some/path/to/website/docs/foo.md -> @site/docs/foo.md
37
+ */
38
+ export declare function aliasedSitePath(filePath: string, siteDir: string): string;
39
+ /**
40
+ * When you have a path like C:\X\Y
41
+ * It is not safe to use directly when generating code
42
+ * For example, this would fail due to unescaped \:
43
+ * `<img src={require('${filePath}')} />`
44
+ * But this would work: `<img src={require('${escapePath(filePath)}')} />`
45
+ *
46
+ * posixPath can't be used in all cases, because forward slashes are only valid
47
+ * Windows paths when they don't contain non-ascii characters, and posixPath
48
+ * doesn't escape those that fail to be converted.
49
+ */
50
+ export declare function escapePath(str: string): string;
51
+ export declare function addTrailingPathSeparator(str: string): string;
52
+ //# sourceMappingURL=pathUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../src/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAeH,eAAO,MAAM,aAAa,QAAS,MAAM,KAAG,OAIgC,CAAC;AAE7E,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAiB7C;AAED;;;;;;;;;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;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK5D"}
@@ -0,0 +1,113 @@
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.addTrailingPathSeparator = exports.escapePath = exports.aliasedSitePath = exports.toMessageRelativeFilePath = exports.posixPath = exports.shortName = exports.isNameTooLong = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const path_1 = tslib_1.__importDefault(require("path"));
12
+ // Based on https://github.com/gatsbyjs/gatsby/pull/21518/files
13
+ // MacOS (APFS) and Windows (NTFS) filename length limit = 255 chars,
14
+ // Others = 255 bytes
15
+ const MAX_PATH_SEGMENT_CHARS = 255;
16
+ const MAX_PATH_SEGMENT_BYTES = 255;
17
+ // Space for appending things to the string like file extensions and so on
18
+ const SPACE_FOR_APPENDING = 10;
19
+ const isMacOs = () => process.platform === 'darwin';
20
+ const isWindows = () => process.platform === 'win32';
21
+ const isNameTooLong = (str) =>
22
+ // Not entirely correct: we can't assume FS from OS. But good enough?
23
+ isMacOs() || isWindows()
24
+ ? str.length + SPACE_FOR_APPENDING > MAX_PATH_SEGMENT_CHARS // MacOS (APFS) and Windows (NTFS) filename length limit (255 chars)
25
+ : Buffer.from(str).length + SPACE_FOR_APPENDING > MAX_PATH_SEGMENT_BYTES; // Other (255 bytes)
26
+ exports.isNameTooLong = isNameTooLong;
27
+ function shortName(str) {
28
+ if (isMacOs() || isWindows()) {
29
+ const overflowingChars = str.length - MAX_PATH_SEGMENT_CHARS;
30
+ return str.slice(0, str.length - overflowingChars - SPACE_FOR_APPENDING - 1);
31
+ }
32
+ const strBuffer = Buffer.from(str);
33
+ const overflowingBytes = Buffer.byteLength(strBuffer) - MAX_PATH_SEGMENT_BYTES;
34
+ return strBuffer
35
+ .slice(0, Buffer.byteLength(strBuffer) - overflowingBytes - SPACE_FOR_APPENDING - 1)
36
+ .toString();
37
+ }
38
+ exports.shortName = shortName;
39
+ /**
40
+ * Convert Windows backslash paths to posix style paths.
41
+ * E.g: endi\lie -> endi/lie
42
+ *
43
+ * Returns original path if the posix counterpart is not valid Windows path.
44
+ * This makes the legacy code that uses posixPath safe; but also makes it less
45
+ * useful when you actually want a path with forward slashes (e.g. for URL)
46
+ *
47
+ * Adopted from https://github.com/sindresorhus/slash/blob/main/index.js
48
+ */
49
+ function posixPath(str) {
50
+ const isExtendedLengthPath = /^\\\\\?\\/.test(str);
51
+ // Forward slashes are only valid Windows paths when they don't contain non-
52
+ // ascii characters.
53
+ // eslint-disable-next-line no-control-regex
54
+ const hasNonAscii = /[^\u0000-\u0080]+/.test(str);
55
+ if (isExtendedLengthPath || hasNonAscii) {
56
+ return str;
57
+ }
58
+ return str.replace(/\\/g, '/');
59
+ }
60
+ exports.posixPath = posixPath;
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
+ */
73
+ function toMessageRelativeFilePath(filePath) {
74
+ return posixPath(path_1.default.relative(process.cwd(), filePath));
75
+ }
76
+ exports.toMessageRelativeFilePath = toMessageRelativeFilePath;
77
+ /**
78
+ * Alias filepath relative to site directory, very useful so that we
79
+ * don't expose user's site structure.
80
+ * Example: some/path/to/website/docs/foo.md -> @site/docs/foo.md
81
+ */
82
+ function aliasedSitePath(filePath, siteDir) {
83
+ const relativePath = posixPath(path_1.default.relative(siteDir, filePath));
84
+ // Cannot use path.join() as it resolves '../' and removes
85
+ // the '@site'. Let webpack loader resolve it.
86
+ return `@site/${relativePath}`;
87
+ }
88
+ exports.aliasedSitePath = aliasedSitePath;
89
+ /**
90
+ * When you have a path like C:\X\Y
91
+ * It is not safe to use directly when generating code
92
+ * For example, this would fail due to unescaped \:
93
+ * `<img src={require('${filePath}')} />`
94
+ * But this would work: `<img src={require('${escapePath(filePath)}')} />`
95
+ *
96
+ * posixPath can't be used in all cases, because forward slashes are only valid
97
+ * Windows paths when they don't contain non-ascii characters, and posixPath
98
+ * doesn't escape those that fail to be converted.
99
+ */
100
+ function escapePath(str) {
101
+ const escaped = JSON.stringify(str);
102
+ // Remove the " around the json string;
103
+ return escaped.substring(1, escaped.length - 1);
104
+ }
105
+ exports.escapePath = escapePath;
106
+ function addTrailingPathSeparator(str) {
107
+ return str.endsWith(path_1.default.sep)
108
+ ? str
109
+ : // If this is Windows, we need to change the forward slash to backward
110
+ `${str.replace(/\/$/, '')}${path_1.default.sep}`;
111
+ }
112
+ exports.addTrailingPathSeparator = addTrailingPathSeparator;
113
+ //# sourceMappingURL=pathUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathUtils.js","sourceRoot":"","sources":["../src/pathUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,wDAAwB;AAExB,+DAA+D;AAC/D,qEAAqE;AACrE,qBAAqB;AACrB,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,0EAA0E;AAC1E,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,CAAC;AACpD,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;AAE9C,MAAM,aAAa,GAAG,CAAC,GAAW,EAAW,EAAE;AACpD,qEAAqE;AACrE,OAAO,EAAE,IAAI,SAAS,EAAE;IACtB,CAAC,CAAC,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;AAJrF,QAAA,aAAa,iBAImD;AAE7E,SAAgB,SAAS,CAAC,GAAW;IACnC,IAAI,OAAO,EAAE,IAAI,SAAS,EAAE,EAAE;QAC5B,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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M,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAEpC,uCAAuC;IACvC,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC;AALD,gCAKC;AAED,SAAgB,wBAAwB,CAAC,GAAW;IAClD,OAAO,GAAG,CAAC,QAAQ,CAAC,cAAI,CAAC,GAAG,CAAC;QAC3B,CAAC,CAAC,GAAG;QACL,CAAC,CAAC,sEAAsE;YACtE,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,cAAI,CAAC,GAAG,EAAE,CAAC;AAC7C,CAAC;AALD,4DAKC"}
@@ -0,0 +1,24 @@
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
+ /** Keep the headings' casing, otherwise make all lowercase. */
9
+ maintainCase?: boolean;
10
+ };
11
+ export declare type Slugger = {
12
+ /**
13
+ * Takes a Markdown heading like "Josh Cena" and sluggifies it according to
14
+ * GitHub semantics (in this case `josh-cena`). Stateful, because if you try
15
+ * to sluggify "Josh Cena" again it would return `josh-cena-1`.
16
+ */
17
+ slug: (value: string, options?: SluggerOptions) => string;
18
+ };
19
+ /**
20
+ * A thin wrapper around github-slugger. This is a factory function that returns
21
+ * a stateful Slugger object.
22
+ */
23
+ export declare function createSlugger(): Slugger;
24
+ //# 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;IAC3B,+DAA+D;IAC/D,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,oBAAY,OAAO,GAAG;IACpB;;;;OAIG;IACH,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,KAAK,MAAM,CAAC;CAC3D,CAAC;AAEF;;;GAGG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAKvC"}
package/lib/slugger.js ADDED
@@ -0,0 +1,23 @@
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 = tslib_1.__importDefault(require("github-slugger"));
12
+ /**
13
+ * A thin wrapper around github-slugger. This is a factory function that returns
14
+ * a stateful Slugger object.
15
+ */
16
+ function createSlugger() {
17
+ const githubSlugger = new github_slugger_1.default();
18
+ return {
19
+ slug: (value, options) => githubSlugger.slug(value, options?.maintainCase),
20
+ };
21
+ }
22
+ exports.createSlugger = createSlugger;
23
+ //# sourceMappingURL=slugger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slugger.js","sourceRoot":"","sources":["../src/slugger.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,4EAA2C;AAmB3C;;;GAGG;AACH,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,EAAE,YAAY,CAAC;KAC3E,CAAC;AACJ,CAAC;AALD,sCAKC"}
package/lib/tags.d.ts ADDED
@@ -0,0 +1,48 @@
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 to this tag's page, without the `/tags/` base path. */
10
+ permalink: string;
11
+ };
12
+ export declare type FrontMatterTag = string | Tag;
13
+ /**
14
+ * Takes tag objects as they are defined in front matter, and normalizes each
15
+ * into a standard tag object. The permalink is created by appending the
16
+ * sluggified label to `tagsPath`. Front matter tags already containing
17
+ * permalinks would still have `tagsPath` prepended.
18
+ *
19
+ * The result will always be unique by permalinks. The behavior with colliding
20
+ * permalinks is undetermined.
21
+ */
22
+ export declare function normalizeFrontMatterTags(
23
+ /** Base path to append the tag permalinks to. */
24
+ tagsPath: string,
25
+ /** Can be `undefined`, so that we can directly pipe in `frontMatter.tags`. */
26
+ frontMatterTags?: FrontMatterTag[] | undefined): Tag[];
27
+ declare type TaggedItemGroup<Item> = {
28
+ tag: Tag;
29
+ items: Item[];
30
+ };
31
+ /**
32
+ * Permits to group docs/blog posts by tag (provided by front matter).
33
+ *
34
+ * @returns a map from tag permalink to the items and other relevant tag data.
35
+ * The record is indexed by permalink, because routes must be unique in the end.
36
+ * Labels may vary on 2 MD files but they are normalized. Docs with
37
+ * label='some label' and label='some-label' should end up in the same page.
38
+ */
39
+ export declare function groupTaggedItems<Item>(items: readonly Item[],
40
+ /**
41
+ * A callback telling me how to get the tags list of the current item. Usually
42
+ * simply getting it from some metadata of the current item.
43
+ */
44
+ getItemTags: (item: Item) => readonly Tag[]): {
45
+ [permalink: string]: TaggedItemGroup<Item>;
46
+ };
47
+ export {};
48
+ //# 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,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,oBAAY,cAAc,GAAG,MAAM,GAAG,GAAG,CAAC;AAgC1C;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB;AACtC,iDAAiD;AACjD,QAAQ,EAAE,MAAM;AAChB,8EAA8E;AAC9E,eAAe,GAAE,cAAc,EAAE,GAAG,SAAc,GACjD,GAAG,EAAE,CAMP;AAED,aAAK,eAAe,CAAC,IAAI,IAAI;IAC3B,GAAG,EAAE,GAAG,CAAC;IACT,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EACnC,KAAK,EAAE,SAAS,IAAI,EAAE;AACtB;;;GAGG;AACH,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,SAAS,GAAG,EAAE,GAC1C;IAAC,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;CAAC,CA0B9C"}
package/lib/tags.js ADDED
@@ -0,0 +1,91 @@
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 = void 0;
10
+ const tslib_1 = require("tslib");
11
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
12
+ const urlUtils_1 = require("./urlUtils");
13
+ function normalizeFrontMatterTag(tagsPath, frontMatterTag) {
14
+ function toTagObject(tagString) {
15
+ return {
16
+ label: tagString,
17
+ permalink: lodash_1.default.kebabCase(tagString),
18
+ };
19
+ }
20
+ // TODO maybe make ensure the permalink is valid url path?
21
+ function normalizeTagPermalink(permalink) {
22
+ // note: we always apply tagsPath on purpose. For versioned docs, v1/doc.md
23
+ // and v2/doc.md tags with custom permalinks don't lead to the same created
24
+ // page. tagsPath is different for each doc version
25
+ return (0, urlUtils_1.normalizeUrl)([tagsPath, permalink]);
26
+ }
27
+ const tag = typeof frontMatterTag === 'string'
28
+ ? toTagObject(frontMatterTag)
29
+ : frontMatterTag;
30
+ return {
31
+ label: tag.label,
32
+ permalink: normalizeTagPermalink(tag.permalink),
33
+ };
34
+ }
35
+ /**
36
+ * Takes tag objects as they are defined in front matter, and normalizes each
37
+ * into a standard tag object. The permalink is created by appending the
38
+ * sluggified label to `tagsPath`. Front matter tags already containing
39
+ * permalinks would still have `tagsPath` prepended.
40
+ *
41
+ * The result will always be unique by permalinks. The behavior with colliding
42
+ * permalinks is undetermined.
43
+ */
44
+ function normalizeFrontMatterTags(
45
+ /** Base path to append the tag permalinks to. */
46
+ tagsPath,
47
+ /** Can be `undefined`, so that we can directly pipe in `frontMatter.tags`. */
48
+ frontMatterTags = []) {
49
+ const tags = frontMatterTags.map((tag) => normalizeFrontMatterTag(tagsPath, tag));
50
+ return lodash_1.default.uniqBy(tags, (tag) => tag.permalink);
51
+ }
52
+ exports.normalizeFrontMatterTags = normalizeFrontMatterTags;
53
+ /**
54
+ * Permits to group docs/blog posts by tag (provided by front matter).
55
+ *
56
+ * @returns a map from tag permalink to the items and other relevant tag data.
57
+ * The record is indexed by permalink, because routes must be unique in the end.
58
+ * Labels may vary on 2 MD files but they are normalized. Docs with
59
+ * label='some label' and label='some-label' should end up in the same page.
60
+ */
61
+ function groupTaggedItems(items,
62
+ /**
63
+ * A callback telling me how to get the tags list of the current item. Usually
64
+ * simply getting it from some metadata of the current item.
65
+ */
66
+ getItemTags) {
67
+ const result = {};
68
+ items.forEach((item) => {
69
+ getItemTags(item).forEach((tag) => {
70
+ var _a;
71
+ // Init missing tag groups
72
+ // TODO: it's not really clear what should be the behavior if 2 tags have
73
+ // the same permalink but the label is different for each
74
+ // For now, the first tag found wins
75
+ result[_a = tag.permalink] ?? (result[_a] = {
76
+ tag,
77
+ items: [],
78
+ });
79
+ // Add item to group
80
+ result[tag.permalink].items.push(item);
81
+ });
82
+ });
83
+ // If user add twice the same tag to a md doc (weird but possible),
84
+ // we don't want the item to appear twice in the list...
85
+ Object.values(result).forEach((group) => {
86
+ group.items = lodash_1.default.uniq(group.items);
87
+ });
88
+ return result;
89
+ }
90
+ exports.groupTaggedItems = groupTaggedItems;
91
+ //# sourceMappingURL=tags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tags.js","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,4DAAuB;AACvB,yCAAwC;AAUxC,SAAS,uBAAuB,CAC9B,QAAgB,EAChB,cAA8B;IAE9B,SAAS,WAAW,CAAC,SAAiB;QACpC,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,SAAS,EAAE,gBAAC,CAAC,SAAS,CAAC,SAAS,CAAC;SAClC,CAAC;IACJ,CAAC;IAED,0DAA0D;IAC1D,SAAS,qBAAqB,CAAC,SAAiB;QAC9C,2EAA2E;QAC3E,2EAA2E;QAC3E,mDAAmD;QACnD,OAAO,IAAA,uBAAY,EAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,GAAG,GACP,OAAO,cAAc,KAAK,QAAQ;QAChC,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC;QAC7B,CAAC,CAAC,cAAc,CAAC;IAErB,OAAO;QACL,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,SAAS,EAAE,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC;KAChD,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,wBAAwB;AACtC,iDAAiD;AACjD,QAAgB;AAChB,8EAA8E;AAC9E,kBAAgD,EAAE;IAElD,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACvC,uBAAuB,CAAC,QAAQ,EAAE,GAAG,CAAC,CACvC,CAAC;IAEF,OAAO,gBAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAChD,CAAC;AAXD,4DAWC;AAOD;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAC9B,KAAsB;AACtB;;;GAGG;AACH,WAA2C;IAE3C,MAAM,MAAM,GAAiD,EAAE,CAAC;IAEhE,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACrB,WAAW,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;;YAChC,0BAA0B;YAC1B,yEAAyE;YACzE,yDAAyD;YACzD,oCAAoC;YACpC,MAAM,MAAC,GAAG,CAAC,SAAS,MAApB,MAAM,OAAoB;gBACxB,GAAG;gBACH,KAAK,EAAE,EAAE;aACV,EAAC;YAEF,oBAAoB;YACpB,MAAM,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,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,gBAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAjCD,4CAiCC"}
@@ -0,0 +1,66 @@
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
+ * Much like `path.join`, but much better. Takes an array of URL segments, and
9
+ * joins them into a reasonable URL.
10
+ *
11
+ * - `["file:", "/home", "/user/", "website"]` => `file:///home/user/website`
12
+ * - `["file://", "home", "/user/", "website"]` => `file://home/user/website` (relative!)
13
+ * - Remove trailing slash before parameters or hash.
14
+ * - Replace `?` in query parameters with `&`.
15
+ * - Dedupe forward slashes in the entire path, avoiding protocol slashes.
16
+ *
17
+ * @throws {TypeError} If any of the URL segment is not a string, this throws.
18
+ */
19
+ export declare function normalizeUrl(rawUrls: string[]): string;
20
+ /**
21
+ * Takes a file's path, relative to its content folder, and computes its edit
22
+ * URL. If `editUrl` is `undefined`, this returns `undefined`, as is the case
23
+ * when the user doesn't want an edit URL in her config.
24
+ */
25
+ export declare function getEditUrl(fileRelativePath: string, editUrl?: string): string | undefined;
26
+ /**
27
+ * Converts file path to a reasonable URL path, e.g. `'index.md'` -> `'/'`,
28
+ * `'foo/bar.js'` -> `'/foo/bar'`
29
+ */
30
+ export declare function fileToPath(file: string): string;
31
+ /**
32
+ * Similar to `encodeURI`, but uses `encodeURIComponent` and assumes there's no
33
+ * query.
34
+ *
35
+ * `encodeURI("/question?/answer")` => `"/question?/answer#section"`;
36
+ * `encodePath("/question?/answer#section")` => `"/question%3F/answer%23foo"`
37
+ */
38
+ export declare function encodePath(userPath: string): string;
39
+ /**
40
+ * Whether `str` is a valid pathname. It must be absolute, and not contain
41
+ * special characters.
42
+ */
43
+ export declare function isValidPathname(str: string): boolean;
44
+ /**
45
+ * Resolve pathnames and fail-fast if resolution fails. Uses standard URL
46
+ * semantics (provided by `resolve-pathname` which is used internally by React
47
+ * router)
48
+ */
49
+ export declare function resolvePathname(to: string, from?: string): string;
50
+ /** Appends a leading slash to `str`, if one doesn't exist. */
51
+ export declare function addLeadingSlash(str: string): string;
52
+ /** Appends a trailing slash to `str`, if one doesn't exist. */
53
+ export declare function addTrailingSlash(str: string): string;
54
+ /** Removes the trailing slash from `str`. */
55
+ export declare function removeTrailingSlash(str: string): string;
56
+ /** Constructs an SSH URL that can be used to push to GitHub. */
57
+ export declare function buildSshUrl(githubHost: string, organizationName: string, projectName: string, githubPort?: string): string;
58
+ /** Constructs an HTTP URL that can be used to push to GitHub. */
59
+ export declare function buildHttpsUrl(gitCredentials: string, githubHost: string, organizationName: string, projectName: string, githubPort?: string): string;
60
+ /**
61
+ * Whether the current URL is an SSH protocol. In addition to looking for
62
+ * `ssh:`, it will also allow protocol-less URLs like
63
+ * `git@github.com:facebook/docusaurus.git`.
64
+ */
65
+ export declare function hasSSHProtocol(sourceRepoUrl: string): boolean;
66
+ //# sourceMappingURL=urlUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlUtils.d.ts","sourceRoot":"","sources":["../src/urlUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAoFtD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,gBAAgB,EAAE,MAAM,EACxB,OAAO,CAAC,EAAE,MAAM,GACf,MAAM,GAAG,SAAS,CAKpB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ/C;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKnD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAWpD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjE;AACD,8DAA8D;AAC9D,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnD;AAGD,+DAA+D;AAC/D,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,6CAA6C;AAC7C,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,gEAAgE;AAChE,wBAAgB,WAAW,CACzB,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,GAClB,MAAM,CAKR;AAED,iEAAiE;AACjE,wBAAgB,aAAa,CAC3B,cAAc,EAAE,MAAM,EAC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