@docusaurus/utils 2.0.0-beta.17 → 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 (86) hide show
  1. package/lib/constants.d.ts +49 -1
  2. package/lib/constants.d.ts.map +1 -1
  3. package/lib/constants.js +53 -8
  4. package/lib/constants.js.map +1 -1
  5. package/lib/dataFileUtils.d.ts +38 -2
  6. package/lib/dataFileUtils.d.ts.map +1 -1
  7. package/lib/dataFileUtils.js +34 -8
  8. package/lib/dataFileUtils.js.map +1 -1
  9. package/lib/emitUtils.d.ts +12 -0
  10. package/lib/emitUtils.d.ts.map +1 -1
  11. package/lib/emitUtils.js +24 -7
  12. package/lib/emitUtils.js.map +1 -1
  13. package/lib/gitUtils.d.ts +54 -5
  14. package/lib/gitUtils.d.ts.map +1 -1
  15. package/lib/gitUtils.js +14 -11
  16. package/lib/gitUtils.js.map +1 -1
  17. package/lib/globUtils.d.ts +27 -0
  18. package/lib/globUtils.d.ts.map +1 -1
  19. package/lib/globUtils.js +28 -10
  20. package/lib/globUtils.js.map +1 -1
  21. package/lib/hashUtils.d.ts +5 -4
  22. package/lib/hashUtils.d.ts.map +1 -1
  23. package/lib/hashUtils.js +6 -5
  24. package/lib/hashUtils.js.map +1 -1
  25. package/lib/i18nUtils.d.ts +11 -0
  26. package/lib/i18nUtils.d.ts.map +1 -1
  27. package/lib/i18nUtils.js +12 -3
  28. package/lib/i18nUtils.js.map +1 -1
  29. package/lib/index.d.ts +7 -7
  30. package/lib/index.d.ts.map +1 -1
  31. package/lib/index.js +16 -11
  32. package/lib/index.js.map +1 -1
  33. package/lib/jsUtils.d.ts +32 -4
  34. package/lib/jsUtils.d.ts.map +1 -1
  35. package/lib/jsUtils.js +35 -13
  36. package/lib/jsUtils.js.map +1 -1
  37. package/lib/markdownLinks.d.ts +48 -5
  38. package/lib/markdownLinks.d.ts.map +1 -1
  39. package/lib/markdownLinks.js +21 -11
  40. package/lib/markdownLinks.js.map +1 -1
  41. package/lib/markdownUtils.d.ts +112 -0
  42. package/lib/markdownUtils.d.ts.map +1 -0
  43. package/lib/markdownUtils.js +271 -0
  44. package/lib/markdownUtils.js.map +1 -0
  45. package/lib/pathUtils.d.ts +1 -1
  46. package/lib/pathUtils.d.ts.map +1 -1
  47. package/lib/pathUtils.js +2 -2
  48. package/lib/pathUtils.js.map +1 -1
  49. package/lib/slugger.d.ts +10 -0
  50. package/lib/slugger.d.ts.map +1 -1
  51. package/lib/slugger.js +4 -0
  52. package/lib/slugger.js.map +1 -1
  53. package/lib/tags.d.ts +31 -10
  54. package/lib/tags.d.ts.map +1 -1
  55. package/lib/tags.js +38 -23
  56. package/lib/tags.js.map +1 -1
  57. package/lib/urlUtils.d.ts +48 -2
  58. package/lib/urlUtils.d.ts.map +1 -1
  59. package/lib/urlUtils.js +81 -9
  60. package/lib/urlUtils.js.map +1 -1
  61. package/lib/webpackUtils.d.ts +5 -0
  62. package/lib/webpackUtils.d.ts.map +1 -1
  63. package/lib/webpackUtils.js +6 -2
  64. package/lib/webpackUtils.js.map +1 -1
  65. package/package.json +9 -9
  66. package/src/constants.ts +61 -9
  67. package/src/dataFileUtils.ts +43 -11
  68. package/src/emitUtils.ts +26 -9
  69. package/src/gitUtils.ts +76 -16
  70. package/src/globUtils.ts +29 -13
  71. package/src/hashUtils.ts +6 -5
  72. package/src/i18nUtils.ts +13 -4
  73. package/src/index.ts +14 -8
  74. package/src/jsUtils.ts +34 -20
  75. package/src/markdownLinks.ts +64 -27
  76. package/src/markdownUtils.ts +354 -0
  77. package/src/pathUtils.ts +2 -2
  78. package/src/slugger.ts +13 -1
  79. package/src/tags.ts +39 -27
  80. package/src/urlUtils.ts +96 -10
  81. package/src/webpackUtils.ts +10 -2
  82. package/lib/markdownParser.d.ts +0 -32
  83. package/lib/markdownParser.d.ts.map +0 -1
  84. package/lib/markdownParser.js +0 -160
  85. package/lib/markdownParser.js.map +0 -1
  86. package/src/markdownParser.ts +0 -201
package/lib/globUtils.js CHANGED
@@ -11,34 +11,52 @@ const tslib_1 = require("tslib");
11
11
  // Globby/Micromatch are the 2 libs we use in Docusaurus consistently
12
12
  const micromatch_1 = tslib_1.__importDefault(require("micromatch")); // Note: Micromatch is used by Globby
13
13
  const path_1 = tslib_1.__importDefault(require("path"));
14
+ /** A re-export of the globby instance. */
14
15
  var globby_1 = require("globby");
15
16
  Object.defineProperty(exports, "Globby", { enumerable: true, get: function () { return tslib_1.__importDefault(globby_1).default; } });
16
- // The default patterns we ignore when globbing
17
- // using _ prefix for exclusion by convention
17
+ /**
18
+ * The default glob patterns we ignore when sourcing content.
19
+ * - Ignore files and folders starting with `_` recursively
20
+ * - Ignore tests
21
+ */
18
22
  exports.GlobExcludeDefault = [
19
- // Ignore files starting with _
20
23
  '**/_*.{js,jsx,ts,tsx,md,mdx}',
21
- // Ignore folders starting with _ (including folder content)
22
24
  '**/_*/**',
23
- // Ignore tests
24
25
  '**/*.test.{js,jsx,ts,tsx}',
25
26
  '**/__tests__/**',
26
27
  ];
28
+ /**
29
+ * A very thin wrapper around `Micromatch.makeRe`.
30
+ *
31
+ * @see {@link createAbsoluteFilePathMatcher}
32
+ * @param patterns A list of glob patterns.
33
+ * @returns A matcher handle that tells if a file path is matched by any of the
34
+ * patterns.
35
+ */
27
36
  function createMatcher(patterns) {
28
37
  const regexp = new RegExp(patterns.map((pattern) => micromatch_1.default.makeRe(pattern).source).join('|'));
29
38
  return (str) => regexp.test(str);
30
39
  }
31
40
  exports.createMatcher = createMatcher;
32
- // We use match patterns like '**/_*/**',
33
- // This function permits to help to:
34
- // Match /user/sebastien/website/docs/_partials/xyz.md
35
- // Ignore /user/_sebastien/website/docs/partials/xyz.md
41
+ /**
42
+ * We use match patterns like `"** /_* /**"` (ignore the spaces), where `"_*"`
43
+ * should only be matched within a subfolder. This function would:
44
+ * - Match `/user/sebastien/website/docs/_partials/xyz.md`
45
+ * - Ignore `/user/_sebastien/website/docs/partials/xyz.md`
46
+ *
47
+ * @param patterns A list of glob patterns.
48
+ * @param rootFolders A list of root folders to resolve the glob from.
49
+ * @returns A matcher handle that tells if a file path is matched by any of the
50
+ * patterns, resolved from the first root folder that contains the path.
51
+ * @throws Throws when the returned matcher receives a path that doesn't belong
52
+ * to any of the `rootFolders`.
53
+ */
36
54
  function createAbsoluteFilePathMatcher(patterns, rootFolders) {
37
55
  const matcher = createMatcher(patterns);
38
56
  function getRelativeFilePath(absoluteFilePath) {
39
57
  const rootFolder = rootFolders.find((folderPath) => absoluteFilePath.startsWith(folderPath));
40
58
  if (!rootFolder) {
41
- throw new Error(`createAbsoluteFilePathMatcher unexpected error, absoluteFilePath=${absoluteFilePath} was not contained in any of the root folders ${JSON.stringify(rootFolders)}`);
59
+ throw new Error(`createAbsoluteFilePathMatcher unexpected error, absoluteFilePath=${absoluteFilePath} was not contained in any of the root folders: ${rootFolders.join(', ')}`);
42
60
  }
43
61
  return path_1.default.relative(rootFolder, absoluteFilePath);
44
62
  }
@@ -1 +1 @@
1
- {"version":3,"file":"globUtils.js","sourceRoot":"","sources":["../src/globUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,qEAAqE;AAErE,oEAAoC,CAAC,qCAAqC;AAC1E,wDAAwB;AAExB,iCAAyC;AAAjC,yHAAA,OAAO,OAAU;AAEzB,+CAA+C;AAC/C,6CAA6C;AAChC,QAAA,kBAAkB,GAAG;IAChC,+BAA+B;IAC/B,8BAA8B;IAE9B,4DAA4D;IAC5D,UAAU;IAEV,eAAe;IACf,2BAA2B;IAC3B,iBAAiB;CAClB,CAAC;AAIF,SAAgB,aAAa,CAAC,QAAkB;IAC9C,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,oBAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CACvE,CAAC;IACF,OAAO,CAAC,GAAG,EAA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MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CACvE,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AALD,sCAKC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,6BAA6B,CAC3C,QAAkB,EAClB,WAAqB;IAErB,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IAExC,SAAS,mBAAmB,CAAC,gBAAwB;QACnD,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CACjD,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,CACxC,CAAC;QACF,IAAI,CAAC,UAAU,EAAE;YACf,MAAM,IAAI,KAAK,CACb,oEAAoE,gBAAgB,kDAAkD,WAAW,CAAC,IAAI,CACpJ,IAAI,CACL,EAAE,CACJ,CAAC;SACH;QACD,OAAO,cAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,CAAC,gBAAwB,EAAE,EAAE,CAClC,OAAO,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,CAAC;AACnD,CAAC;AAtBD,sEAsBC"}
@@ -4,13 +4,14 @@
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
+ /** Thin wrapper around `crypto.createHash("md5")`. */
7
8
  export declare function md5Hash(str: string): string;
9
+ /** Creates an MD5 hash and truncates it to the given length. */
8
10
  export declare function simpleHash(str: string, length: number): string;
9
11
  /**
10
- * Given an input string, convert to kebab-case and append a hash.
11
- * Avoid str collision.
12
- * Also removes part of the string if its larger than the allowed
13
- * filename per OS. Avoids ERRNAMETOOLONG error.
12
+ * Given an input string, convert to kebab-case and append a hash, avoiding name
13
+ * collision. Also removes part of the string if its larger than the allowed
14
+ * filename per OS, avoiding `ERRNAMETOOLONG` error.
14
15
  */
15
16
  export declare function docuHash(str: string): string;
16
17
  //# sourceMappingURL=hashUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hashUtils.d.ts","sourceRoot":"","sources":["../src/hashUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE9D;AAGD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAU5C"}
1
+ {"version":3,"file":"hashUtils.d.ts","sourceRoot":"","sources":["../src/hashUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,sDAAsD;AACtD,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,gEAAgE;AAChE,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE9D;AAGD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAU5C"}
package/lib/hashUtils.js CHANGED
@@ -11,20 +11,21 @@ const tslib_1 = require("tslib");
11
11
  const crypto_1 = require("crypto");
12
12
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
13
13
  const pathUtils_1 = require("./pathUtils");
14
+ /** Thin wrapper around `crypto.createHash("md5")`. */
14
15
  function md5Hash(str) {
15
16
  return (0, crypto_1.createHash)('md5').update(str).digest('hex');
16
17
  }
17
18
  exports.md5Hash = md5Hash;
19
+ /** Creates an MD5 hash and truncates it to the given length. */
18
20
  function simpleHash(str, length) {
19
- return md5Hash(str).substr(0, length);
21
+ return md5Hash(str).substring(0, length);
20
22
  }
21
23
  exports.simpleHash = simpleHash;
22
24
  // Based on https://github.com/gatsbyjs/gatsby/pull/21518/files
23
25
  /**
24
- * Given an input string, convert to kebab-case and append a hash.
25
- * Avoid str collision.
26
- * Also removes part of the string if its larger than the allowed
27
- * filename per OS. Avoids ERRNAMETOOLONG error.
26
+ * Given an input string, convert to kebab-case and append a hash, avoiding name
27
+ * collision. Also removes part of the string if its larger than the allowed
28
+ * filename per OS, avoiding `ERRNAMETOOLONG` error.
28
29
  */
29
30
  function docuHash(str) {
30
31
  if (str === '/') {
@@ -1 +1 @@
1
- {"version":3,"file":"hashUtils.js","sourceRoot":"","sources":["../src/hashUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,mCAAkC;AAClC,4DAAuB;AACvB,2CAAqD;AAErD,SAAgB,OAAO,CAAC,GAAW;IACjC,OAAO,IAAA,mBAAU,EAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC;AAFD,0BAEC;AAED,SAAgB,UAAU,CAAC,GAAW,EAAE,MAAc;IACpD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACxC,CAAC;AAFD,gCAEC;AAED,+DAA+D;AAC/D;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,GAAW;IAClC,IAAI,GAAG,KAAK,GAAG,EAAE;QACf,OAAO,OAAO,CAAC;KAChB;IACD,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,GAAG,gBAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,SAAS,EAAE,CAAC;IACtD,IAAI,IAAA,yBAAa,EAAC,UAAU,CAAC,EAAE;QAC7B,OAAO,GAAG,IAAA,qBAAS,EAAC,gBAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC;KACtD;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAVD,4BAUC"}
1
+ {"version":3,"file":"hashUtils.js","sourceRoot":"","sources":["../src/hashUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,mCAAkC;AAClC,4DAAuB;AACvB,2CAAqD;AAErD,sDAAsD;AACtD,SAAgB,OAAO,CAAC,GAAW;IACjC,OAAO,IAAA,mBAAU,EAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC;AAFD,0BAEC;AAED,gEAAgE;AAChE,SAAgB,UAAU,CAAC,GAAW,EAAE,MAAc;IACpD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AAC3C,CAAC;AAFD,gCAEC;AAED,+DAA+D;AAC/D;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,GAAW;IAClC,IAAI,GAAG,KAAK,GAAG,EAAE;QACf,OAAO,OAAO,CAAC;KAChB;IACD,MAAM,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,GAAG,gBAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,SAAS,EAAE,CAAC;IACtD,IAAI,IAAA,yBAAa,EAAC,UAAU,CAAC,EAAE;QAC7B,OAAO,GAAG,IAAA,qBAAS,EAAC,gBAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC;KACtD;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAVD,4BAUC"}
@@ -5,8 +5,19 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { TranslationFileContent, TranslationFile } from '@docusaurus/types';
8
+ /**
9
+ * Takes a list of translation file contents, and shallow-merges them into one.
10
+ */
8
11
  export declare function mergeTranslations(contents: TranslationFileContent[]): TranslationFileContent;
12
+ /**
13
+ * Useful to update all the messages of a translation file. Used in tests to
14
+ * simulate translations.
15
+ */
9
16
  export declare function updateTranslationFileMessages(translationFile: TranslationFile, updateMessage: (message: string) => string): TranslationFile;
17
+ /**
18
+ * Takes everything needed and constructs a plugin i18n path. Plugins should
19
+ * expect everything it needs for translations to be found under this path.
20
+ */
10
21
  export declare function getPluginI18nPath({ siteDir, locale, pluginName, pluginId, subPaths, }: {
11
22
  siteDir: string;
12
23
  locale: string;
@@ -1 +1 @@
1
- {"version":3,"file":"i18nUtils.d.ts","sourceRoot":"","sources":["../src/i18nUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAC,sBAAsB,EAAE,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAG/E,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,sBAAsB,EAAE,GACjC,sBAAsB,CAExB;AAID,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GACzC,eAAe,CAQjB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,EACN,UAAU,EACV,QAA4B,EAC5B,QAAa,GACd,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,GAAG,MAAM,CAYT"}
1
+ {"version":3,"file":"i18nUtils.d.ts","sourceRoot":"","sources":["../src/i18nUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAC,sBAAsB,EAAE,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAG/E;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,sBAAsB,EAAE,GACjC,sBAAsB,CAExB;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GACzC,eAAe,CAQjB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,EACN,UAAU,EACV,QAA4B,EAC5B,QAAa,GACd,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,GAAG,MAAM,CAYT"}
package/lib/i18nUtils.js CHANGED
@@ -11,12 +11,17 @@ const tslib_1 = require("tslib");
11
11
  const path_1 = tslib_1.__importDefault(require("path"));
12
12
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
13
13
  const constants_1 = require("./constants");
14
+ /**
15
+ * Takes a list of translation file contents, and shallow-merges them into one.
16
+ */
14
17
  function mergeTranslations(contents) {
15
18
  return contents.reduce((acc, content) => ({ ...acc, ...content }), {});
16
19
  }
17
20
  exports.mergeTranslations = mergeTranslations;
18
- // Useful to update all the messages of a translation file
19
- // Used in tests to simulate translations
21
+ /**
22
+ * Useful to update all the messages of a translation file. Used in tests to
23
+ * simulate translations.
24
+ */
20
25
  function updateTranslationFileMessages(translationFile, updateMessage) {
21
26
  return {
22
27
  ...translationFile,
@@ -27,8 +32,12 @@ function updateTranslationFileMessages(translationFile, updateMessage) {
27
32
  };
28
33
  }
29
34
  exports.updateTranslationFileMessages = updateTranslationFileMessages;
35
+ /**
36
+ * Takes everything needed and constructs a plugin i18n path. Plugins should
37
+ * expect everything it needs for translations to be found under this path.
38
+ */
30
39
  function getPluginI18nPath({ siteDir, locale, pluginName, pluginId = constants_1.DEFAULT_PLUGIN_ID, subPaths = [], }) {
31
- return path_1.default.join(siteDir, 'i18n',
40
+ return path_1.default.join(siteDir, constants_1.I18N_DIR_NAME,
32
41
  // namespace first by locale: convenient to work in a single folder for a
33
42
  // translator
34
43
  locale,
@@ -1 +1 @@
1
- {"version":3,"file":"i18nUtils.js","sourceRoot":"","sources":["../src/i18nUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,wDAAwB;AACxB,4DAAuB;AAEvB,2CAA8C;AAE9C,SAAgB,iBAAiB,CAC/B,QAAkC;IAElC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,EAAC,GAAG,GAAG,EAAE,GAAG,OAAO,EAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACvE,CAAC;AAJD,8CAIC;AAED,0DAA0D;AAC1D,yCAAyC;AACzC,SAAgB,6BAA6B,CAC3C,eAAgC,EAChC,aAA0C;IAE1C,OAAO;QACL,GAAG,eAAe;QAClB,OAAO,EAAE,gBAAC,CAAC,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YAC9D,GAAG,WAAW;YACd,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC;SAC5C,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAXD,sEAWC;AAED,SAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,EACN,UAAU,EACV,QAAQ,GAAG,6BAAiB,EAC5B,QAAQ,GAAG,EAAE,GAOd;IACC,OAAO,cAAI,CAAC,IAAI,CACd,OAAO,EACP,MAAM;IACN,yEAAyE;IACzE,aAAa;IACb,MAAM;IACN,gDAAgD;IAChD,2DAA2D;IAC3D,GAAG,UAAU,GAAG,QAAQ,KAAK,6BAAiB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,EAAE,EACtE,GAAG,QAAQ,CACZ,CAAC;AACJ,CAAC;AAxBD,8CAwBC"}
1
+ {"version":3,"file":"i18nUtils.js","sourceRoot":"","sources":["../src/i18nUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,wDAAwB;AACxB,4DAAuB;AAEvB,2CAA6D;AAE7D;;GAEG;AACH,SAAgB,iBAAiB,CAC/B,QAAkC;IAElC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,EAAC,GAAG,GAAG,EAAE,GAAG,OAAO,EAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACvE,CAAC;AAJD,8CAIC;AAED;;;GAGG;AACH,SAAgB,6BAA6B,CAC3C,eAAgC,EAChC,aAA0C;IAE1C,OAAO;QACL,GAAG,eAAe;QAClB,OAAO,EAAE,gBAAC,CAAC,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YAC9D,GAAG,WAAW;YACd,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC;SAC5C,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAXD,sEAWC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,MAAM,EACN,UAAU,EACV,QAAQ,GAAG,6BAAiB,EAC5B,QAAQ,GAAG,EAAE,GAOd;IACC,OAAO,cAAI,CAAC,IAAI,CACd,OAAO,EACP,yBAAa;IACb,yEAAyE;IACzE,aAAa;IACb,MAAM;IACN,gDAAgD;IAChD,2DAA2D;IAC3D,GAAG,UAAU,GAAG,QAAQ,KAAK,6BAAiB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,EAAE,EACtE,GAAG,QAAQ,CACZ,CAAC;AACJ,CAAC;AAxBD,8CAwBC"}
package/lib/index.d.ts CHANGED
@@ -4,15 +4,15 @@
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 { NODE_MAJOR_VERSION, NODE_MINOR_VERSION, DEFAULT_BUILD_DIR_NAME, DEFAULT_CONFIG_FILE_NAME, BABEL_CONFIG_FILE_NAME, GENERATED_FILES_DIR_NAME, SRC_DIR_NAME, STATIC_DIR_NAME, OUTPUT_STATIC_ASSETS_DIR_NAME, THEME_PATH, DEFAULT_PORT, DEFAULT_PLUGIN_ID, WEBPACK_URL_LOADER_LIMIT, } from './constants';
7
+ export { NODE_MAJOR_VERSION, NODE_MINOR_VERSION, DEFAULT_BUILD_DIR_NAME, DEFAULT_CONFIG_FILE_NAME, BABEL_CONFIG_FILE_NAME, GENERATED_FILES_DIR_NAME, SRC_DIR_NAME, DEFAULT_STATIC_DIR_NAME, OUTPUT_STATIC_ASSETS_DIR_NAME, THEME_PATH, I18N_DIR_NAME, CODE_TRANSLATIONS_FILE_NAME, DEFAULT_PORT, DEFAULT_PLUGIN_ID, WEBPACK_URL_LOADER_LIMIT, } from './constants';
8
8
  export { generate, genChunkName, readOutputHTMLFile } from './emitUtils';
9
- export { getFileCommitDate, GitNotFoundError } from './gitUtils';
9
+ export { getFileCommitDate, FileNotTrackedError, GitNotFoundError, } from './gitUtils';
10
10
  export { mergeTranslations, updateTranslationFileMessages, getPluginI18nPath, } from './i18nUtils';
11
- export { removeSuffix, removePrefix, getElementsAround, mapAsyncSequential, findAsyncSequential, reportMessage, } from './jsUtils';
12
- export { normalizeUrl, getEditUrl, fileToPath, encodePath, isValidPathname, resolvePathname, addLeadingSlash, addTrailingSlash, removeTrailingSlash, } from './urlUtils';
13
- export { type Tag, type FrontMatterTag, type TaggedItemGroup, normalizeFrontMatterTag, normalizeFrontMatterTags, groupTaggedItems, } from './tags';
14
- export { parseMarkdownHeadingId, createExcerpt, parseFrontMatter, parseMarkdownContentTitle, parseMarkdownString, } from './markdownParser';
15
- export { type ContentPaths, type BrokenMarkdownLink, type ReplaceMarkdownLinksParams, type ReplaceMarkdownLinksReturn, replaceMarkdownLinks, } from './markdownLinks';
11
+ export { removeSuffix, removePrefix, mapAsyncSequential, findAsyncSequential, reportMessage, } from './jsUtils';
12
+ export { normalizeUrl, getEditUrl, fileToPath, encodePath, isValidPathname, resolvePathname, addLeadingSlash, addTrailingSlash, removeTrailingSlash, hasSSHProtocol, buildHttpsUrl, buildSshUrl, } from './urlUtils';
13
+ export { type Tag, type FrontMatterTag, normalizeFrontMatterTags, groupTaggedItems, } from './tags';
14
+ export { parseMarkdownHeadingId, createExcerpt, parseFrontMatter, parseMarkdownContentTitle, parseMarkdownString, writeMarkdownHeadingId, type WriteHeadingIDOptions, } from './markdownUtils';
15
+ export { type ContentPaths, type BrokenMarkdownLink, replaceMarkdownLinks, } from './markdownLinks';
16
16
  export { type SluggerOptions, type Slugger, createSlugger } from './slugger';
17
17
  export { isNameTooLong, shortName, posixPath, toMessageRelativeFilePath, aliasedSitePath, escapePath, addTrailingPathSeparator, } from './pathUtils';
18
18
  export { md5Hash, simpleHash, docuHash } from './hashUtils';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EACZ,eAAe,EACf,6BAA6B,EAC7B,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAE,kBAAkB,EAAC,MAAM,aAAa,CAAC;AACvE,OAAO,EAAC,iBAAiB,EAAE,gBAAgB,EAAC,MAAM,YAAY,CAAC;AAC/D,OAAO,EACL,iBAAiB,EACjB,6BAA6B,EAC7B,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,YAAY,EACZ,UAAU,EACV,UAAU,EACV,UAAU,EACV,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,gBAAgB,EAChB,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,aAAa,EAAC,MAAM,WAAW,CAAC;AAC3E,OAAO,EACL,aAAa,EACb,SAAS,EACT,SAAS,EACT,yBAAyB,EACzB,eAAe,EACf,UAAU,EACV,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAC;AAC1D,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,aAAa,EACb,6BAA6B,GAC9B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EACL,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EACZ,uBAAuB,EACvB,6BAA6B,EAC7B,UAAU,EACV,aAA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B,EAClB,aAAa,EACb,6BAA6B,GAC9B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EACL,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC"}
package/lib/index.js CHANGED
@@ -6,8 +6,8 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.toMessageRelativeFilePath = exports.posixPath = exports.shortName = exports.isNameTooLong = exports.createSlugger = exports.replaceMarkdownLinks = exports.parseMarkdownString = exports.parseMarkdownContentTitle = exports.parseFrontMatter = exports.createExcerpt = exports.parseMarkdownHeadingId = exports.groupTaggedItems = exports.normalizeFrontMatterTags = exports.normalizeFrontMatterTag = exports.removeTrailingSlash = exports.addTrailingSlash = exports.addLeadingSlash = exports.resolvePathname = exports.isValidPathname = exports.encodePath = exports.fileToPath = exports.getEditUrl = exports.normalizeUrl = exports.reportMessage = exports.findAsyncSequential = exports.mapAsyncSequential = exports.getElementsAround = exports.removePrefix = exports.removeSuffix = exports.getPluginI18nPath = exports.updateTranslationFileMessages = exports.mergeTranslations = exports.GitNotFoundError = exports.getFileCommitDate = exports.readOutputHTMLFile = exports.genChunkName = exports.generate = exports.WEBPACK_URL_LOADER_LIMIT = exports.DEFAULT_PLUGIN_ID = exports.DEFAULT_PORT = exports.THEME_PATH = exports.OUTPUT_STATIC_ASSETS_DIR_NAME = exports.STATIC_DIR_NAME = exports.SRC_DIR_NAME = exports.GENERATED_FILES_DIR_NAME = exports.BABEL_CONFIG_FILE_NAME = exports.DEFAULT_CONFIG_FILE_NAME = exports.DEFAULT_BUILD_DIR_NAME = exports.NODE_MINOR_VERSION = exports.NODE_MAJOR_VERSION = void 0;
10
- exports.getFolderContainingFile = exports.findFolderContainingFile = exports.getContentPathList = exports.getDataFileData = exports.getDataFilePath = exports.getFileLoaderUtils = exports.createAbsoluteFilePathMatcher = exports.createMatcher = exports.GlobExcludeDefault = exports.Globby = exports.docuHash = exports.simpleHash = exports.md5Hash = exports.addTrailingPathSeparator = exports.escapePath = exports.aliasedSitePath = void 0;
9
+ exports.replaceMarkdownLinks = exports.writeMarkdownHeadingId = exports.parseMarkdownString = exports.parseMarkdownContentTitle = exports.parseFrontMatter = exports.createExcerpt = exports.parseMarkdownHeadingId = exports.groupTaggedItems = exports.normalizeFrontMatterTags = exports.buildSshUrl = exports.buildHttpsUrl = exports.hasSSHProtocol = exports.removeTrailingSlash = exports.addTrailingSlash = exports.addLeadingSlash = exports.resolvePathname = exports.isValidPathname = exports.encodePath = exports.fileToPath = exports.getEditUrl = exports.normalizeUrl = exports.reportMessage = exports.findAsyncSequential = exports.mapAsyncSequential = exports.removePrefix = exports.removeSuffix = exports.getPluginI18nPath = exports.updateTranslationFileMessages = exports.mergeTranslations = exports.GitNotFoundError = exports.FileNotTrackedError = exports.getFileCommitDate = exports.readOutputHTMLFile = exports.genChunkName = exports.generate = exports.WEBPACK_URL_LOADER_LIMIT = exports.DEFAULT_PLUGIN_ID = exports.DEFAULT_PORT = exports.CODE_TRANSLATIONS_FILE_NAME = exports.I18N_DIR_NAME = exports.THEME_PATH = exports.OUTPUT_STATIC_ASSETS_DIR_NAME = exports.DEFAULT_STATIC_DIR_NAME = exports.SRC_DIR_NAME = exports.GENERATED_FILES_DIR_NAME = exports.BABEL_CONFIG_FILE_NAME = exports.DEFAULT_CONFIG_FILE_NAME = exports.DEFAULT_BUILD_DIR_NAME = exports.NODE_MINOR_VERSION = exports.NODE_MAJOR_VERSION = void 0;
10
+ exports.getFolderContainingFile = exports.findFolderContainingFile = exports.getContentPathList = exports.getDataFileData = exports.getDataFilePath = exports.getFileLoaderUtils = exports.createAbsoluteFilePathMatcher = exports.createMatcher = exports.GlobExcludeDefault = exports.Globby = exports.docuHash = exports.simpleHash = exports.md5Hash = exports.addTrailingPathSeparator = exports.escapePath = exports.aliasedSitePath = exports.toMessageRelativeFilePath = exports.posixPath = exports.shortName = exports.isNameTooLong = exports.createSlugger = void 0;
11
11
  var constants_1 = require("./constants");
12
12
  Object.defineProperty(exports, "NODE_MAJOR_VERSION", { enumerable: true, get: function () { return constants_1.NODE_MAJOR_VERSION; } });
13
13
  Object.defineProperty(exports, "NODE_MINOR_VERSION", { enumerable: true, get: function () { return constants_1.NODE_MINOR_VERSION; } });
@@ -16,9 +16,11 @@ Object.defineProperty(exports, "DEFAULT_CONFIG_FILE_NAME", { enumerable: true, g
16
16
  Object.defineProperty(exports, "BABEL_CONFIG_FILE_NAME", { enumerable: true, get: function () { return constants_1.BABEL_CONFIG_FILE_NAME; } });
17
17
  Object.defineProperty(exports, "GENERATED_FILES_DIR_NAME", { enumerable: true, get: function () { return constants_1.GENERATED_FILES_DIR_NAME; } });
18
18
  Object.defineProperty(exports, "SRC_DIR_NAME", { enumerable: true, get: function () { return constants_1.SRC_DIR_NAME; } });
19
- Object.defineProperty(exports, "STATIC_DIR_NAME", { enumerable: true, get: function () { return constants_1.STATIC_DIR_NAME; } });
19
+ Object.defineProperty(exports, "DEFAULT_STATIC_DIR_NAME", { enumerable: true, get: function () { return constants_1.DEFAULT_STATIC_DIR_NAME; } });
20
20
  Object.defineProperty(exports, "OUTPUT_STATIC_ASSETS_DIR_NAME", { enumerable: true, get: function () { return constants_1.OUTPUT_STATIC_ASSETS_DIR_NAME; } });
21
21
  Object.defineProperty(exports, "THEME_PATH", { enumerable: true, get: function () { return constants_1.THEME_PATH; } });
22
+ Object.defineProperty(exports, "I18N_DIR_NAME", { enumerable: true, get: function () { return constants_1.I18N_DIR_NAME; } });
23
+ Object.defineProperty(exports, "CODE_TRANSLATIONS_FILE_NAME", { enumerable: true, get: function () { return constants_1.CODE_TRANSLATIONS_FILE_NAME; } });
22
24
  Object.defineProperty(exports, "DEFAULT_PORT", { enumerable: true, get: function () { return constants_1.DEFAULT_PORT; } });
23
25
  Object.defineProperty(exports, "DEFAULT_PLUGIN_ID", { enumerable: true, get: function () { return constants_1.DEFAULT_PLUGIN_ID; } });
24
26
  Object.defineProperty(exports, "WEBPACK_URL_LOADER_LIMIT", { enumerable: true, get: function () { return constants_1.WEBPACK_URL_LOADER_LIMIT; } });
@@ -28,6 +30,7 @@ Object.defineProperty(exports, "genChunkName", { enumerable: true, get: function
28
30
  Object.defineProperty(exports, "readOutputHTMLFile", { enumerable: true, get: function () { return emitUtils_1.readOutputHTMLFile; } });
29
31
  var gitUtils_1 = require("./gitUtils");
30
32
  Object.defineProperty(exports, "getFileCommitDate", { enumerable: true, get: function () { return gitUtils_1.getFileCommitDate; } });
33
+ Object.defineProperty(exports, "FileNotTrackedError", { enumerable: true, get: function () { return gitUtils_1.FileNotTrackedError; } });
31
34
  Object.defineProperty(exports, "GitNotFoundError", { enumerable: true, get: function () { return gitUtils_1.GitNotFoundError; } });
32
35
  var i18nUtils_1 = require("./i18nUtils");
33
36
  Object.defineProperty(exports, "mergeTranslations", { enumerable: true, get: function () { return i18nUtils_1.mergeTranslations; } });
@@ -36,7 +39,6 @@ Object.defineProperty(exports, "getPluginI18nPath", { enumerable: true, get: fun
36
39
  var jsUtils_1 = require("./jsUtils");
37
40
  Object.defineProperty(exports, "removeSuffix", { enumerable: true, get: function () { return jsUtils_1.removeSuffix; } });
38
41
  Object.defineProperty(exports, "removePrefix", { enumerable: true, get: function () { return jsUtils_1.removePrefix; } });
39
- Object.defineProperty(exports, "getElementsAround", { enumerable: true, get: function () { return jsUtils_1.getElementsAround; } });
40
42
  Object.defineProperty(exports, "mapAsyncSequential", { enumerable: true, get: function () { return jsUtils_1.mapAsyncSequential; } });
41
43
  Object.defineProperty(exports, "findAsyncSequential", { enumerable: true, get: function () { return jsUtils_1.findAsyncSequential; } });
42
44
  Object.defineProperty(exports, "reportMessage", { enumerable: true, get: function () { return jsUtils_1.reportMessage; } });
@@ -50,16 +52,19 @@ Object.defineProperty(exports, "resolvePathname", { enumerable: true, get: funct
50
52
  Object.defineProperty(exports, "addLeadingSlash", { enumerable: true, get: function () { return urlUtils_1.addLeadingSlash; } });
51
53
  Object.defineProperty(exports, "addTrailingSlash", { enumerable: true, get: function () { return urlUtils_1.addTrailingSlash; } });
52
54
  Object.defineProperty(exports, "removeTrailingSlash", { enumerable: true, get: function () { return urlUtils_1.removeTrailingSlash; } });
55
+ Object.defineProperty(exports, "hasSSHProtocol", { enumerable: true, get: function () { return urlUtils_1.hasSSHProtocol; } });
56
+ Object.defineProperty(exports, "buildHttpsUrl", { enumerable: true, get: function () { return urlUtils_1.buildHttpsUrl; } });
57
+ Object.defineProperty(exports, "buildSshUrl", { enumerable: true, get: function () { return urlUtils_1.buildSshUrl; } });
53
58
  var tags_1 = require("./tags");
54
- Object.defineProperty(exports, "normalizeFrontMatterTag", { enumerable: true, get: function () { return tags_1.normalizeFrontMatterTag; } });
55
59
  Object.defineProperty(exports, "normalizeFrontMatterTags", { enumerable: true, get: function () { return tags_1.normalizeFrontMatterTags; } });
56
60
  Object.defineProperty(exports, "groupTaggedItems", { enumerable: true, get: function () { return tags_1.groupTaggedItems; } });
57
- var markdownParser_1 = require("./markdownParser");
58
- Object.defineProperty(exports, "parseMarkdownHeadingId", { enumerable: true, get: function () { return markdownParser_1.parseMarkdownHeadingId; } });
59
- Object.defineProperty(exports, "createExcerpt", { enumerable: true, get: function () { return markdownParser_1.createExcerpt; } });
60
- Object.defineProperty(exports, "parseFrontMatter", { enumerable: true, get: function () { return markdownParser_1.parseFrontMatter; } });
61
- Object.defineProperty(exports, "parseMarkdownContentTitle", { enumerable: true, get: function () { return markdownParser_1.parseMarkdownContentTitle; } });
62
- Object.defineProperty(exports, "parseMarkdownString", { enumerable: true, get: function () { return markdownParser_1.parseMarkdownString; } });
61
+ var markdownUtils_1 = require("./markdownUtils");
62
+ Object.defineProperty(exports, "parseMarkdownHeadingId", { enumerable: true, get: function () { return markdownUtils_1.parseMarkdownHeadingId; } });
63
+ Object.defineProperty(exports, "createExcerpt", { enumerable: true, get: function () { return markdownUtils_1.createExcerpt; } });
64
+ Object.defineProperty(exports, "parseFrontMatter", { enumerable: true, get: function () { return markdownUtils_1.parseFrontMatter; } });
65
+ Object.defineProperty(exports, "parseMarkdownContentTitle", { enumerable: true, get: function () { return markdownUtils_1.parseMarkdownContentTitle; } });
66
+ Object.defineProperty(exports, "parseMarkdownString", { enumerable: true, get: function () { return markdownUtils_1.parseMarkdownString; } });
67
+ Object.defineProperty(exports, "writeMarkdownHeadingId", { enumerable: true, get: function () { return markdownUtils_1.writeMarkdownHeadingId; } });
63
68
  var markdownLinks_1 = require("./markdownLinks");
64
69
  Object.defineProperty(exports, "replaceMarkdownLinks", { enumerable: true, get: function () { return markdownLinks_1.replaceMarkdownLinks; } });
65
70
  var slugger_1 = require("./slugger");
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,yCAcqB;AAbnB,+GAAA,kBAAkB,OAAA;AAClB,+GAAA,kBAAkB,OAAA;AAClB,mHAAA,sBAAsB,OAAA;AACtB,qHAAA,wBAAwB,OAAA;AACxB,mHAAA,sBAAsB,OAAA;AACtB,qHAAA,wBAAwB,OAAA;AACxB,yGAAA,YAAY,OAAA;AACZ,4GAAA,eAAe,OAAA;AACf,0HAAA,6BAA6B,OAAA;AAC7B,uGAAA,UAAU,OAAA;AACV,yGAAA,YAAY,OAAA;AACZ,8GAAA,iBAAiB,OAAA;AACjB,qHAAA,wBAAwB,OAAA;AAE1B,yCAAuE;AAA/D,qGAAA,QAAQ,OAAA;AAAE,yGAAA,YAAY,OAAA;AAAE,+GAAA,kBAAkB,OAAA;AAClD,uCAA+D;AAAvD,6GAAA,iBAAiB,OAAA;AAAE,4GAAA,gBAAgB,OAAA;AAC3C,yCAIqB;AAHnB,8GAAA,iBAAiB,OAAA;AACjB,0HAAA,6BAA6B,OAAA;AAC7B,8GAAA,iBAAiB,OAAA;AAEnB,qCAOmB;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4GAAA,gBAAgB,OAAA;AAChB,+GAAA,mBAAmB,OAAA;AACnB,0GAAA,cAAc,OAAA;AACd,yGAAA,aAAa,OAAA;AACb,uGAAA,WAAW,OAAA;AAEb,+BAKgB;AAFd,gHAAA,wBAAwB,OAAA;AACxB,wGAAA,gBAAgB,OAAA;AAElB,iDAQyB;AAPvB,uHAAA,sBAAsB,OAAA;AACtB,8GAAA,aAAa,OAAA;AACb,iHAAA,gBAAgB,OAAA;AAChB,0HAAA,yBAAyB,OAAA;AACzB,oHAAA,mBAAmB,OAAA;AACnB,uHAAA,sBAAsB,OAAA;AAGxB,iDAIyB;AADvB,qHAAA,oBAAoB,OAAA;AAEtB,qCAA2E;AAAhC,wGAAA,aAAa,OAAA;AACxD,yCAQqB;AAPnB,0GAAA,aAAa,OAAA;AACb,sGAAA,SAAS,OAAA;AACT,sGAAA,SAAS,OAAA;AACT,sHAAA,yBAAyB,OAAA;AACzB,4GAAA,eAAe,OAAA;AACf,uGAAA,UAAU,OAAA;AACV,qHAAA,wBAAwB,OAAA;AAE1B,yCAA0D;AAAlD,oGAAA,OAAO,OAAA;AAAE,uGAAA,UAAU,OAAA;AAAE,qGAAA,QAAQ,OAAA;AACrC,yCAKqB;AAJnB,mGAAA,MAAM,OAAA;AACN,+GAAA,kBAAkB,OAAA;AAClB,0GAAA,aAAa,OAAA;AACb,0HAAA,6BAA6B,OAAA;AAE/B,+CAAkD;AAA1C,kHAAA,kBAAkB,OAAA;AAC1B,iDAMyB;AALvB,gHAAA,eAAe,OAAA;AACf,gHAAA,eAAe,OAAA;AACf,mHAAA,kBAAkB,OAAA;AAClB,yHAAA,wBAAwB,OAAA;AACxB,wHAAA,uBAAuB,OAAA"}
package/lib/jsUtils.d.ts CHANGED
@@ -5,13 +5,41 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { ReportingSeverity } from '@docusaurus/types';
8
+ /** Removes a given string suffix from `str`. */
8
9
  export declare function removeSuffix(str: string, suffix: string): string;
10
+ /** Removes a given string prefix from `str`. */
9
11
  export declare function removePrefix(str: string, prefix: string): string;
10
- export declare function getElementsAround<T>(array: T[], aroundIndex: number): {
11
- next: T | undefined;
12
- previous: T | undefined;
13
- };
12
+ /**
13
+ * `Array#map` for async operations where order matters.
14
+ * @param array The array to traverse.
15
+ * @param action An async action to be performed on every array item. Will be
16
+ * awaited before working on the next.
17
+ * @returns The list of results returned from every `action(item)`
18
+ */
14
19
  export declare function mapAsyncSequential<T, R>(array: T[], action: (t: T) => Promise<R>): Promise<R[]>;
20
+ /**
21
+ * `Array#find` for async operations where order matters.
22
+ * @param array The array to traverse.
23
+ * @param predicate An async predicate to be called on every array item. Should
24
+ * return a boolean indicating whether the currently element should be returned.
25
+ * @returns The function immediately returns the first item on which `predicate`
26
+ * returns `true`, or `undefined` if none matches the predicate.
27
+ */
15
28
  export declare function findAsyncSequential<T>(array: T[], predicate: (t: T) => Promise<boolean>): Promise<T | undefined>;
29
+ /**
30
+ * Takes a message and reports it according to the severity that the user wants.
31
+ *
32
+ * - `ignore`: completely no-op
33
+ * - `log`: uses the `INFO` log level
34
+ * - `warn`: uses the `WARN` log level
35
+ * - `error`: uses the `ERROR` log level
36
+ * - `throw`: aborts the process, throws the error.
37
+ *
38
+ * Since the logger doesn't have logging level filters yet, these severities
39
+ * mostly just differ by their colors.
40
+ *
41
+ * @throws In addition to throwing when `reportingSeverity === "throw"`, this
42
+ * function also throws if `reportingSeverity` is not one of the above.
43
+ */
16
44
  export declare function reportMessage(message: string, reportingSeverity: ReportingSeverity): void;
17
45
  //# sourceMappingURL=jsUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsUtils.d.ts","sourceRoot":"","sources":["../src/jsUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AAGzD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,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AC,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAC3B,OAAO,CAAC,CAAC,EAAE,CAAC,CAOd;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,GACpC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAOxB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,iBAAiB,EAAE,iBAAiB,GACnC,IAAI,CAoBN"}
package/lib/jsUtils.js CHANGED
@@ -6,31 +6,30 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.reportMessage = exports.findAsyncSequential = exports.mapAsyncSequential = exports.getElementsAround = exports.removePrefix = exports.removeSuffix = void 0;
9
+ exports.reportMessage = exports.findAsyncSequential = exports.mapAsyncSequential = exports.removePrefix = exports.removeSuffix = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
+ /** Removes a given string suffix from `str`. */
12
13
  function removeSuffix(str, suffix) {
13
14
  if (suffix === '') {
14
- return str; // always returns "" otherwise!
15
+ // str.slice(0, 0) is ""
16
+ return str;
15
17
  }
16
18
  return str.endsWith(suffix) ? str.slice(0, -suffix.length) : str;
17
19
  }
18
20
  exports.removeSuffix = removeSuffix;
21
+ /** Removes a given string prefix from `str`. */
19
22
  function removePrefix(str, prefix) {
20
23
  return str.startsWith(prefix) ? str.slice(prefix.length) : str;
21
24
  }
22
25
  exports.removePrefix = removePrefix;
23
- function getElementsAround(array, aroundIndex) {
24
- const min = 0;
25
- const max = array.length - 1;
26
- if (aroundIndex < min || aroundIndex > max) {
27
- throw new Error(`Valid "aroundIndex" for array (of size ${array.length}) are between ${min} and ${max}, but you provided ${aroundIndex}.`);
28
- }
29
- const previous = aroundIndex === min ? undefined : array[aroundIndex - 1];
30
- const next = aroundIndex === max ? undefined : array[aroundIndex + 1];
31
- return { previous, next };
32
- }
33
- exports.getElementsAround = getElementsAround;
26
+ /**
27
+ * `Array#map` for async operations where order matters.
28
+ * @param array The array to traverse.
29
+ * @param action An async action to be performed on every array item. Will be
30
+ * awaited before working on the next.
31
+ * @returns The list of results returned from every `action(item)`
32
+ */
34
33
  async function mapAsyncSequential(array, action) {
35
34
  const results = [];
36
35
  for (const t of array) {
@@ -40,6 +39,14 @@ async function mapAsyncSequential(array, action) {
40
39
  return results;
41
40
  }
42
41
  exports.mapAsyncSequential = mapAsyncSequential;
42
+ /**
43
+ * `Array#find` for async operations where order matters.
44
+ * @param array The array to traverse.
45
+ * @param predicate An async predicate to be called on every array item. Should
46
+ * return a boolean indicating whether the currently element should be returned.
47
+ * @returns The function immediately returns the first item on which `predicate`
48
+ * returns `true`, or `undefined` if none matches the predicate.
49
+ */
43
50
  async function findAsyncSequential(array, predicate) {
44
51
  for (const t of array) {
45
52
  if (await predicate(t)) {
@@ -49,6 +56,21 @@ async function findAsyncSequential(array, predicate) {
49
56
  return undefined;
50
57
  }
51
58
  exports.findAsyncSequential = findAsyncSequential;
59
+ /**
60
+ * Takes a message and reports it according to the severity that the user wants.
61
+ *
62
+ * - `ignore`: completely no-op
63
+ * - `log`: uses the `INFO` log level
64
+ * - `warn`: uses the `WARN` log level
65
+ * - `error`: uses the `ERROR` log level
66
+ * - `throw`: aborts the process, throws the error.
67
+ *
68
+ * Since the logger doesn't have logging level filters yet, these severities
69
+ * mostly just differ by their colors.
70
+ *
71
+ * @throws In addition to throwing when `reportingSeverity === "throw"`, this
72
+ * function also throws if `reportingSeverity` is not one of the above.
73
+ */
52
74
  function reportMessage(message, reportingSeverity) {
53
75
  switch (reportingSeverity) {
54
76
  case 'ignore':
@@ -1 +1 @@
1
- {"version":3,"file":"jsUtils.js","sourceRoot":"","sources":["../src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T,gBAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACrB,MAAM;QACR,KAAK,OAAO;YACV,gBAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACtB,MAAM;QACR,KAAK,OAAO;YACV,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B;YACE,MAAM,IAAI,KAAK,CACb,yCAAyC,iBAAiB,GAAG,CAC9D,CAAC;KACL;AACH,CAAC;AAvBD,sCAuBC"}
@@ -4,25 +4,68 @@
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
+ /**
8
+ * Content plugins have a base path and a localized path to source content from.
9
+ * We will look into the localized path in priority.
10
+ */
7
11
  export declare type ContentPaths = {
12
+ /**
13
+ * The absolute path to the base content directory, like `"<siteDir>/docs"`.
14
+ */
8
15
  contentPath: string;
16
+ /**
17
+ * The absolute path to the localized content directory, like
18
+ * `"<siteDir>/i18n/zh-Hans/plugin-content-docs"`.
19
+ */
9
20
  contentPathLocalized: string;
10
21
  };
22
+ /** Data structure representing each broken Markdown link to be reported. */
11
23
  export declare type BrokenMarkdownLink<T extends ContentPaths> = {
24
+ /** Absolute path to the file containing this link. */
12
25
  filePath: string;
26
+ /**
27
+ * This is generic because it may contain extra metadata like version name,
28
+ * which the reporter can provide for context.
29
+ */
13
30
  contentPaths: T;
31
+ /**
32
+ * The content of the link, like `"./brokenFile.md"`
33
+ */
14
34
  link: string;
15
35
  };
16
- export declare type ReplaceMarkdownLinksParams<T extends ContentPaths> = {
36
+ /**
37
+ * Takes a Markdown file and replaces relative file references with their URL
38
+ * counterparts, e.g. `[link](./intro.md)` => `[link](/docs/intro)`, preserving
39
+ * everything else.
40
+ *
41
+ * This method uses best effort to find a matching file. The file reference can
42
+ * be relative to the directory of the current file (most likely) or any of the
43
+ * content paths (so `/tutorials/intro.md` can be resolved as
44
+ * `<siteDir>/docs/tutorials/intro.md`). Links that contain the `http(s):` or
45
+ * `@site/` prefix will always be ignored.
46
+ */
47
+ export declare function replaceMarkdownLinks<T extends ContentPaths>({ siteDir, fileString, filePath, contentPaths, sourceToPermalink, }: {
48
+ /** Absolute path to the site directory, used to resolve aliased paths. */
17
49
  siteDir: string;
50
+ /** The Markdown file content to be processed. */
18
51
  fileString: string;
52
+ /** Absolute path to the current file containing `fileString`. */
19
53
  filePath: string;
54
+ /** The content paths which the file reference may live in. */
20
55
  contentPaths: T;
21
- sourceToPermalink: Record<string, string>;
22
- };
23
- export declare type ReplaceMarkdownLinksReturn<T extends ContentPaths> = {
56
+ /**
57
+ * A map from source paths to their URLs. Source paths are `@site` aliased.
58
+ */
59
+ sourceToPermalink: {
60
+ [aliasedPath: string]: string;
61
+ };
62
+ }): {
63
+ /**
64
+ * The content with all Markdown file references replaced with their URLs.
65
+ * Unresolved links are left as-is.
66
+ */
24
67
  newContent: string;
68
+ /** The list of broken links, */
25
69
  brokenMarkdownLinks: BrokenMarkdownLink<T>[];
26
70
  };
27
- export declare function replaceMarkdownLinks<T extends ContentPaths>({ siteDir, fileString, filePath, contentPaths, sourceToPermalink, }: ReplaceMarkdownLinksParams<T>): ReplaceMarkdownLinksReturn<T>;
28
71
  //# sourceMappingURL=markdownLinks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"markdownLinks.d.ts","sourceRoot":"","sources":["../src/markdownLinks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,oBAAY,YAAY,GAAG;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,oBAAY,kBAAkB,CAAC,CAAC,SAAS,YAAY,IAAI;IACvD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,CAAC,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,oBAAY,0BAA0B,CAAC,CAAC,SAAS,YAAY,IAAI;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,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