@docusaurus/utils 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/hashUtils.d.ts +4 -1
- package/lib/hashUtils.d.ts.map +1 -1
- package/lib/hashUtils.js +9 -3
- package/lib/hashUtils.js.map +1 -1
- package/lib/index.d.ts +4 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -4
- package/lib/index.js.map +1 -1
- package/lib/markdownLinks.d.ts +7 -34
- package/lib/markdownLinks.d.ts.map +1 -1
- package/lib/markdownLinks.js +22 -104
- package/lib/markdownLinks.js.map +1 -1
- package/lib/tags.d.ts +35 -18
- package/lib/tags.d.ts.map +1 -1
- package/lib/tags.js +57 -28
- package/lib/tags.js.map +1 -1
- package/lib/urlUtils.d.ts +14 -0
- package/lib/urlUtils.d.ts.map +1 -1
- package/lib/urlUtils.js +66 -19
- package/lib/urlUtils.js.map +1 -1
- package/package.json +6 -5
- package/src/hashUtils.ts +20 -3
- package/src/index.ts +11 -3
- package/src/markdownLinks.ts +32 -151
- package/src/tags.ts +121 -36
- package/src/urlUtils.ts +76 -22
package/lib/hashUtils.d.ts
CHANGED
|
@@ -13,5 +13,8 @@ export declare function simpleHash(str: string, length: number): string;
|
|
|
13
13
|
* collision. Also removes part of the string if its larger than the allowed
|
|
14
14
|
* filename per OS, avoiding `ERRNAMETOOLONG` error.
|
|
15
15
|
*/
|
|
16
|
-
export declare function docuHash(
|
|
16
|
+
export declare function docuHash(strInput: string, options?: {
|
|
17
|
+
hashExtra?: string;
|
|
18
|
+
hashLength?: number;
|
|
19
|
+
}): string;
|
|
17
20
|
//# sourceMappingURL=hashUtils.d.ts.map
|
package/lib/hashUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CACtB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;IAGR,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GACA,MAAM,CAkBR"}
|
package/lib/hashUtils.js
CHANGED
|
@@ -27,11 +27,17 @@ exports.simpleHash = simpleHash;
|
|
|
27
27
|
* collision. Also removes part of the string if its larger than the allowed
|
|
28
28
|
* filename per OS, avoiding `ERRNAMETOOLONG` error.
|
|
29
29
|
*/
|
|
30
|
-
function docuHash(
|
|
31
|
-
|
|
30
|
+
function docuHash(strInput, options) {
|
|
31
|
+
// TODO check this historical behavior
|
|
32
|
+
// I'm not sure it makes sense to keep it...
|
|
33
|
+
if (strInput === '/' && typeof options?.hashExtra === 'undefined') {
|
|
32
34
|
return 'index';
|
|
33
35
|
}
|
|
34
|
-
const
|
|
36
|
+
const str = strInput === '/' ? 'index' : strInput;
|
|
37
|
+
const hashExtra = options?.hashExtra ?? '';
|
|
38
|
+
const hashLength = options?.hashLength ?? 3;
|
|
39
|
+
const stringToHash = str + hashExtra;
|
|
40
|
+
const shortHash = simpleHash(stringToHash, hashLength);
|
|
35
41
|
const parsedPath = `${lodash_1.default.kebabCase(str)}-${shortHash}`;
|
|
36
42
|
if ((0, pathUtils_1.isNameTooLong)(parsedPath)) {
|
|
37
43
|
return `${(0, pathUtils_1.shortName)(lodash_1.default.kebabCase(str))}-${shortHash}`;
|
package/lib/hashUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CACtB,QAAgB,EAChB,OAMC;IAED,sCAAsC;IACtC,6CAA6C;IAC7C,IAAI,QAAQ,KAAK,GAAG,IAAI,OAAO,OAAO,EAAE,SAAS,KAAK,WAAW,EAAE,CAAC;QAClE,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,MAAM,GAAG,GAAG,QAAQ,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;IAElD,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,EAAE,CAAC;IAC3C,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,CAAC,CAAC;IAE5C,MAAM,YAAY,GAAG,GAAG,GAAG,SAAS,CAAC;IACrC,MAAM,SAAS,GAAG,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,GAAG,gBAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,SAAS,EAAE,CAAC;IACtD,IAAI,IAAA,yBAAa,EAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,GAAG,IAAA,qBAAS,EAAC,gBAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC;IACvD,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AA3BD,4BA2BC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -9,11 +9,11 @@ export { generate, readOutputHTMLFile } from './emitUtils';
|
|
|
9
9
|
export { getFileCommitDate, FileNotTrackedError, GitNotFoundError, } from './gitUtils';
|
|
10
10
|
export { mergeTranslations, updateTranslationFileMessages, getPluginI18nPath, localizePath, } from './i18nUtils';
|
|
11
11
|
export { mapAsyncSequential, findAsyncSequential } from './jsUtils';
|
|
12
|
-
export { normalizeUrl, getEditUrl, fileToPath, encodePath, isValidPathname, resolvePathname, parseURLPath, serializeURLPath, hasSSHProtocol, buildHttpsUrl, buildSshUrl, } from './urlUtils';
|
|
12
|
+
export { normalizeUrl, getEditUrl, fileToPath, encodePath, isValidPathname, resolvePathname, parseURLPath, parseLocalURLPath, parseURLOrPath, toURLPath, serializeURLPath, hasSSHProtocol, buildHttpsUrl, buildSshUrl, } from './urlUtils';
|
|
13
13
|
export type { URLPath } from './urlUtils';
|
|
14
|
-
export { type Tag, type TagsListItem, type TagModule, type FrontMatterTag,
|
|
14
|
+
export { type Tag, type TagsFile, type TagsFileInput, type TagMetadata, type TagsListItem, type TagModule, type FrontMatterTag, type TagsPluginOptions, groupTaggedItems, getTagVisibility, } from './tags';
|
|
15
15
|
export { parseMarkdownHeadingId, escapeMarkdownHeadingIds, unwrapMdxCodeBlocks, admonitionTitleToDirectiveLabel, createExcerpt, DEFAULT_PARSE_FRONT_MATTER, parseMarkdownContentTitle, parseMarkdownFile, writeMarkdownHeadingId, type WriteHeadingIDOptions, } from './markdownUtils';
|
|
16
|
-
export { type ContentPaths, type
|
|
16
|
+
export { type ContentPaths, type SourceToPermalink, resolveMarkdownLinkPathname, } from './markdownLinks';
|
|
17
17
|
export { type SluggerOptions, type Slugger, createSlugger } from './slugger';
|
|
18
18
|
export { isNameTooLong, shortName, posixPath, toMessageRelativeFilePath, aliasedSitePath, aliasedSitePathToRelativePath, escapePath, addTrailingPathSeparator, } from './pathUtils';
|
|
19
19
|
export { md5Hash, simpleHash, docuHash } from './hashUtils';
|
|
@@ -27,4 +27,5 @@ export { escapeRegexp } from './regExpUtils';
|
|
|
27
27
|
export { askPreferredLanguage } from './cliUtils';
|
|
28
28
|
export { flattenRoutes } from './routeUtils';
|
|
29
29
|
export { getGitLastUpdate, getLastUpdate, readLastUpdateData, LAST_UPDATE_FALLBACK, type LastUpdateData, type FrontMatterLastUpdate, } from './lastUpdateUtils';
|
|
30
|
+
export { normalizeTags, reportInlineTags } from './tags';
|
|
30
31
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EACZ,uBAAuB,EACvB,6BAA6B,EAC7B,UAAU,EACV,qBAAqB,EACrB,2BAA2B,EAC3B,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,QAAQ,EAAE,kBAAkB,EAAC,MAAM,aAAa,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iBAAiB,EACjB,6BAA6B,EAC7B,iBAAiB,EACjB,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,kBAAkB,EAAE,mBAAmB,EAAC,MAAM,WAAW,CAAC;AAClE,OAAO,EACL,YAAY,EACZ,UAAU,EACV,UAAU,EACV,UAAU,EACV,eAAe,EACf,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,YAAY,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AACxC,OAAO,EACL,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,YAAY,EACZ,uBAAuB,EACvB,6BAA6B,EAC7B,UAAU,EACV,q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SAAS,EACT,SAAS,EACT,yBAAyB,EACzB,eAAe,EACf,6BAA6B,EAC7B,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,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,OAAO,EAAE,UAAU,EAAC,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAC,oBAAoB,EAAC,MAAM,YAAY,CAAC;AAChD,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAE3C,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,qBAAqB,GAC3B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,QAAQ,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.
|
|
10
|
-
exports.LAST_UPDATE_FALLBACK = exports.readLastUpdateData = exports.getLastUpdate = exports.getGitLastUpdate = exports.flattenRoutes = exports.askPreferredLanguage = exports.escapeRegexp = exports.isUnlisted = exports.isDraft = exports.getFolderContainingFile = exports.findFolderContainingFile = exports.getContentPathList = exports.getDataFileData = exports.getDataFilePath = exports.loadFreshModule = exports.escapeShellArg = exports.getWebpackLoaderCompilerName = exports.getFileLoaderUtils = exports.createAbsoluteFilePathMatcher = exports.createMatcher = exports.GlobExcludeDefault = exports.Globby = exports.docuHash = exports.simpleHash = exports.md5Hash = exports.addTrailingPathSeparator = exports.escapePath = exports.aliasedSitePathToRelativePath = exports.aliasedSitePath = exports.toMessageRelativeFilePath = exports.posixPath = exports.shortName = exports.isNameTooLong = exports.createSlugger = exports.
|
|
9
|
+
exports.parseMarkdownContentTitle = exports.DEFAULT_PARSE_FRONT_MATTER = exports.createExcerpt = exports.admonitionTitleToDirectiveLabel = exports.unwrapMdxCodeBlocks = exports.escapeMarkdownHeadingIds = exports.parseMarkdownHeadingId = exports.getTagVisibility = exports.groupTaggedItems = exports.buildSshUrl = exports.buildHttpsUrl = exports.hasSSHProtocol = exports.serializeURLPath = exports.toURLPath = exports.parseURLOrPath = exports.parseLocalURLPath = exports.parseURLPath = exports.resolvePathname = exports.isValidPathname = exports.encodePath = exports.fileToPath = exports.getEditUrl = exports.normalizeUrl = exports.findAsyncSequential = exports.mapAsyncSequential = exports.localizePath = exports.getPluginI18nPath = exports.updateTranslationFileMessages = exports.mergeTranslations = exports.GitNotFoundError = exports.FileNotTrackedError = exports.getFileCommitDate = exports.readOutputHTMLFile = exports.generate = exports.WEBPACK_URL_LOADER_LIMIT = exports.DEFAULT_PLUGIN_ID = exports.DEFAULT_PORT = exports.CODE_TRANSLATIONS_FILE_NAME = exports.DEFAULT_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.DOCUSAURUS_VERSION = exports.NODE_MINOR_VERSION = exports.NODE_MAJOR_VERSION = void 0;
|
|
10
|
+
exports.reportInlineTags = exports.normalizeTags = exports.LAST_UPDATE_FALLBACK = exports.readLastUpdateData = exports.getLastUpdate = exports.getGitLastUpdate = exports.flattenRoutes = exports.askPreferredLanguage = exports.escapeRegexp = exports.isUnlisted = exports.isDraft = exports.getFolderContainingFile = exports.findFolderContainingFile = exports.getContentPathList = exports.getDataFileData = exports.getDataFilePath = exports.loadFreshModule = exports.escapeShellArg = exports.getWebpackLoaderCompilerName = exports.getFileLoaderUtils = exports.createAbsoluteFilePathMatcher = exports.createMatcher = exports.GlobExcludeDefault = exports.Globby = exports.docuHash = exports.simpleHash = exports.md5Hash = exports.addTrailingPathSeparator = exports.escapePath = exports.aliasedSitePathToRelativePath = exports.aliasedSitePath = exports.toMessageRelativeFilePath = exports.posixPath = exports.shortName = exports.isNameTooLong = exports.createSlugger = exports.resolveMarkdownLinkPathname = exports.writeMarkdownHeadingId = exports.parseMarkdownFile = 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; } });
|
|
@@ -48,12 +48,14 @@ Object.defineProperty(exports, "encodePath", { enumerable: true, get: function (
|
|
|
48
48
|
Object.defineProperty(exports, "isValidPathname", { enumerable: true, get: function () { return urlUtils_1.isValidPathname; } });
|
|
49
49
|
Object.defineProperty(exports, "resolvePathname", { enumerable: true, get: function () { return urlUtils_1.resolvePathname; } });
|
|
50
50
|
Object.defineProperty(exports, "parseURLPath", { enumerable: true, get: function () { return urlUtils_1.parseURLPath; } });
|
|
51
|
+
Object.defineProperty(exports, "parseLocalURLPath", { enumerable: true, get: function () { return urlUtils_1.parseLocalURLPath; } });
|
|
52
|
+
Object.defineProperty(exports, "parseURLOrPath", { enumerable: true, get: function () { return urlUtils_1.parseURLOrPath; } });
|
|
53
|
+
Object.defineProperty(exports, "toURLPath", { enumerable: true, get: function () { return urlUtils_1.toURLPath; } });
|
|
51
54
|
Object.defineProperty(exports, "serializeURLPath", { enumerable: true, get: function () { return urlUtils_1.serializeURLPath; } });
|
|
52
55
|
Object.defineProperty(exports, "hasSSHProtocol", { enumerable: true, get: function () { return urlUtils_1.hasSSHProtocol; } });
|
|
53
56
|
Object.defineProperty(exports, "buildHttpsUrl", { enumerable: true, get: function () { return urlUtils_1.buildHttpsUrl; } });
|
|
54
57
|
Object.defineProperty(exports, "buildSshUrl", { enumerable: true, get: function () { return urlUtils_1.buildSshUrl; } });
|
|
55
58
|
var tags_1 = require("./tags");
|
|
56
|
-
Object.defineProperty(exports, "normalizeFrontMatterTags", { enumerable: true, get: function () { return tags_1.normalizeFrontMatterTags; } });
|
|
57
59
|
Object.defineProperty(exports, "groupTaggedItems", { enumerable: true, get: function () { return tags_1.groupTaggedItems; } });
|
|
58
60
|
Object.defineProperty(exports, "getTagVisibility", { enumerable: true, get: function () { return tags_1.getTagVisibility; } });
|
|
59
61
|
var markdownUtils_1 = require("./markdownUtils");
|
|
@@ -67,7 +69,7 @@ Object.defineProperty(exports, "parseMarkdownContentTitle", { enumerable: true,
|
|
|
67
69
|
Object.defineProperty(exports, "parseMarkdownFile", { enumerable: true, get: function () { return markdownUtils_1.parseMarkdownFile; } });
|
|
68
70
|
Object.defineProperty(exports, "writeMarkdownHeadingId", { enumerable: true, get: function () { return markdownUtils_1.writeMarkdownHeadingId; } });
|
|
69
71
|
var markdownLinks_1 = require("./markdownLinks");
|
|
70
|
-
Object.defineProperty(exports, "
|
|
72
|
+
Object.defineProperty(exports, "resolveMarkdownLinkPathname", { enumerable: true, get: function () { return markdownLinks_1.resolveMarkdownLinkPathname; } });
|
|
71
73
|
var slugger_1 = require("./slugger");
|
|
72
74
|
Object.defineProperty(exports, "createSlugger", { enumerable: true, get: function () { return slugger_1.createSlugger; } });
|
|
73
75
|
var pathUtils_1 = require("./pathUtils");
|
|
@@ -115,4 +117,7 @@ Object.defineProperty(exports, "getGitLastUpdate", { enumerable: true, get: func
|
|
|
115
117
|
Object.defineProperty(exports, "getLastUpdate", { enumerable: true, get: function () { return lastUpdateUtils_1.getLastUpdate; } });
|
|
116
118
|
Object.defineProperty(exports, "readLastUpdateData", { enumerable: true, get: function () { return lastUpdateUtils_1.readLastUpdateData; } });
|
|
117
119
|
Object.defineProperty(exports, "LAST_UPDATE_FALLBACK", { enumerable: true, get: function () { return lastUpdateUtils_1.LAST_UPDATE_FALLBACK; } });
|
|
120
|
+
var tags_2 = require("./tags");
|
|
121
|
+
Object.defineProperty(exports, "normalizeTags", { enumerable: true, get: function () { return tags_2.normalizeTags; } });
|
|
122
|
+
Object.defineProperty(exports, "reportInlineTags", { enumerable: true, get: function () { return tags_2.reportInlineTags; } });
|
|
118
123
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,yCAiBqB;AAhBnB,+GAAA,kBAAkB,OAAA;AAClB,+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,oHAAA,uBAAuB,OAAA;AACvB,0HAAA,6BAA6B,OAAA;AAC7B,uGAAA,UAAU,OAAA;AACV,kHAAA,qBAAqB,OAAA;AACrB,wHAAA,2BAA2B,OAAA;AAC3B,yGAAA,YAAY,OAAA;AACZ,8GAAA,iBAAiB,OAAA;AACjB,qHAAA,wBAAwB,OAAA;AAE1B,yCAAyD;AAAjD,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A6B,OAAA;AAE/B,+CAIwB;AAHtB,kHAAA,kBAAkB,OAAA;AAClB,4HAAA,4BAA4B,OAAA;AAG9B,2CAA4C;AAApC,4GAAA,cAAc,OAAA;AACtB,6CAA8C;AAAtC,8GAAA,eAAe,OAAA;AACvB,iDAMyB;AALvB,gHAAA,eAAe,OAAA;AACf,gHAAA,eAAe,OAAA;AACf,mHAAA,kBAAkB,OAAA;AAClB,yHAAA,wBAAwB,OAAA;AACxB,wHAAA,uBAAuB,OAAA;AAEzB,mEAA6D;AAArD,iHAAA,OAAO,OAAA;AAAE,oHAAA,UAAU,OAAA;AAC3B,6CAA2C;AAAnC,2GAAA,YAAY,OAAA;AACpB,uCAAgD;AAAxC,gHAAA,oBAAoB,OAAA;AAC5B,2CAA2C;AAAnC,2GAAA,aAAa,OAAA;AAErB,qDAO2B;AANzB,mHAAA,gBAAgB,OAAA;AAChB,gHAAA,aAAa,OAAA;AACb,qHAAA,kBAAkB,OAAA;AAClB,uHAAA,oBAAoB,OAAA;AAKtB,+BAAuD;AAA/C,qGAAA,aAAa,OAAA;AAAE,wGAAA,gBAAgB,OAAA"}
|
package/lib/markdownLinks.d.ts
CHANGED
|
@@ -33,39 +33,12 @@ export type BrokenMarkdownLink<T extends ContentPaths> = {
|
|
|
33
33
|
*/
|
|
34
34
|
link: string;
|
|
35
35
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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. */
|
|
36
|
+
export type SourceToPermalink = Map<string, // Aliased source path: "@site/docs/content.mdx"
|
|
37
|
+
string>;
|
|
38
|
+
export declare function resolveMarkdownLinkPathname(linkPathname: string, context: {
|
|
39
|
+
sourceFilePath: string;
|
|
40
|
+
sourceToPermalink: SourceToPermalink;
|
|
41
|
+
contentPaths: ContentPaths;
|
|
49
42
|
siteDir: string;
|
|
50
|
-
|
|
51
|
-
fileString: string;
|
|
52
|
-
/** Absolute path to the current file containing `fileString`. */
|
|
53
|
-
filePath: string;
|
|
54
|
-
/** The content paths which the file reference may live in. */
|
|
55
|
-
contentPaths: T;
|
|
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
|
-
*/
|
|
67
|
-
newContent: string;
|
|
68
|
-
/** The list of broken links, */
|
|
69
|
-
brokenMarkdownLinks: BrokenMarkdownLink<T>[];
|
|
70
|
-
};
|
|
43
|
+
}): string | null;
|
|
71
44
|
//# sourceMappingURL=markdownLinks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownLinks.d.ts","sourceRoot":"","sources":["../src/markdownLinks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,4EAA4E;AAC5E,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,YAAY,IAAI;IACvD,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;IAChB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;
|
|
1
|
+
{"version":3,"file":"markdownLinks.d.ts","sourceRoot":"","sources":["../src/markdownLinks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,4EAA4E;AAC5E,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,YAAY,IAAI;IACvD,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,YAAY,EAAE,CAAC,CAAC;IAChB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,GAAG,CACjC,MAAM,EAAE,gDAAgD;AACxD,MAAM,CACP,CAAC;AAKF,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE;IACP,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB,GACA,MAAM,GAAG,IAAI,CAoBf"}
|
package/lib/markdownLinks.js
CHANGED
|
@@ -6,114 +6,32 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
9
|
+
exports.resolveMarkdownLinkPathname = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
12
|
const dataFileUtils_1 = require("./dataFileUtils");
|
|
13
13
|
const pathUtils_1 = require("./pathUtils");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
// Note this is historical logic extracted during a 2024 refactor
|
|
15
|
+
// The algo has been kept exactly as before for retro compatibility
|
|
16
|
+
// See also https://github.com/facebook/docusaurus/pull/10168
|
|
17
|
+
function resolveMarkdownLinkPathname(linkPathname, context) {
|
|
18
|
+
const { sourceFilePath, sourceToPermalink, contentPaths, siteDir } = context;
|
|
19
|
+
const sourceDirsToTry = [];
|
|
20
|
+
// ./file.md and ../file.md are always relative to the current file
|
|
21
|
+
if (!linkPathname.startsWith('./') && !linkPathname.startsWith('../')) {
|
|
22
|
+
sourceDirsToTry.push(...(0, dataFileUtils_1.getContentPathList)(contentPaths), siteDir);
|
|
18
23
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* This method uses best effort to find a matching file. The file reference can
|
|
31
|
-
* be relative to the directory of the current file (most likely) or any of the
|
|
32
|
-
* content paths (so `/tutorials/intro.md` can be resolved as
|
|
33
|
-
* `<siteDir>/docs/tutorials/intro.md`). Links that contain the `http(s):` or
|
|
34
|
-
* `@site/` prefix will always be ignored.
|
|
35
|
-
*/
|
|
36
|
-
function replaceMarkdownLinks({ siteDir, fileString, filePath, contentPaths, sourceToPermalink, }) {
|
|
37
|
-
const brokenMarkdownLinks = [];
|
|
38
|
-
// Replace internal markdown linking (except in fenced blocks).
|
|
39
|
-
let lastOpenCodeFence = null;
|
|
40
|
-
const lines = fileString.split('\n').map((line) => {
|
|
41
|
-
const codeFence = parseCodeFence(line);
|
|
42
|
-
if (codeFence) {
|
|
43
|
-
if (!lastOpenCodeFence) {
|
|
44
|
-
lastOpenCodeFence = codeFence;
|
|
45
|
-
}
|
|
46
|
-
else if (!codeFence.definitelyOpen &&
|
|
47
|
-
lastOpenCodeFence.type === codeFence.type &&
|
|
48
|
-
lastOpenCodeFence.count <= codeFence.count) {
|
|
49
|
-
// All three conditions must be met in order for this to be considered
|
|
50
|
-
// a closing fence.
|
|
51
|
-
lastOpenCodeFence = null;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
if (lastOpenCodeFence) {
|
|
55
|
-
return line;
|
|
56
|
-
}
|
|
57
|
-
let modifiedLine = line;
|
|
58
|
-
// Replace inline-style links or reference-style links e.g:
|
|
59
|
-
// This is [Document 1](doc1.md)
|
|
60
|
-
// [doc1]: doc1.md
|
|
61
|
-
const linkTitlePattern = '(?:\\s+(?:\'.*?\'|".*?"|\\(.*?\\)))?';
|
|
62
|
-
const linkSuffixPattern = '(?:\\?[^#>\\s]+)?(?:#[^>\\s]+)?';
|
|
63
|
-
const linkCapture = (forbidden) => `((?!https?://|@site/)[^${forbidden}#?]+)`;
|
|
64
|
-
const linkURLPattern = `(?:(?!<)${linkCapture('()\\s')}${linkSuffixPattern}|<${linkCapture('>')}${linkSuffixPattern}>)`;
|
|
65
|
-
const linkPattern = new RegExp(`\\[(?:(?!\\]\\().)*\\]\\(\\s*${linkURLPattern}${linkTitlePattern}\\s*\\)|^\\s*\\[[^[\\]]*[^[\\]\\s][^[\\]]*\\]:\\s*${linkURLPattern}${linkTitlePattern}$`, 'dgm');
|
|
66
|
-
let mdMatch = linkPattern.exec(modifiedLine);
|
|
67
|
-
while (mdMatch !== null) {
|
|
68
|
-
// Replace it to correct html link.
|
|
69
|
-
const mdLink = mdMatch.slice(1, 5).find(Boolean);
|
|
70
|
-
const mdLinkRange = mdMatch.indices.slice(1, 5).find(Boolean);
|
|
71
|
-
if (!/\.mdx?$/.test(mdLink)) {
|
|
72
|
-
mdMatch = linkPattern.exec(modifiedLine);
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
const sourcesToTry = [];
|
|
76
|
-
// ./file.md and ../file.md are always relative to the current file
|
|
77
|
-
if (!mdLink.startsWith('./') && !mdLink.startsWith('../')) {
|
|
78
|
-
sourcesToTry.push(...(0, dataFileUtils_1.getContentPathList)(contentPaths), siteDir);
|
|
79
|
-
}
|
|
80
|
-
// /file.md is always relative to the content path
|
|
81
|
-
if (!mdLink.startsWith('/')) {
|
|
82
|
-
sourcesToTry.push(path_1.default.dirname(filePath));
|
|
83
|
-
}
|
|
84
|
-
const aliasedSourceMatch = sourcesToTry
|
|
85
|
-
.map((p) => path_1.default.join(p, decodeURIComponent(mdLink)))
|
|
86
|
-
.map((source) => (0, pathUtils_1.aliasedSitePath)(source, siteDir))
|
|
87
|
-
.find((source) => sourceToPermalink[source]);
|
|
88
|
-
const permalink = aliasedSourceMatch
|
|
89
|
-
? sourceToPermalink[aliasedSourceMatch]
|
|
90
|
-
: undefined;
|
|
91
|
-
if (permalink) {
|
|
92
|
-
// MDX won't be happy if the permalink contains a space, we need to
|
|
93
|
-
// convert it to %20
|
|
94
|
-
const encodedPermalink = permalink
|
|
95
|
-
.split('/')
|
|
96
|
-
.map((part) => part.replace(/\s/g, '%20'))
|
|
97
|
-
.join('/');
|
|
98
|
-
modifiedLine = `${modifiedLine.slice(0, mdLinkRange[0])}${encodedPermalink}${modifiedLine.slice(mdLinkRange[1])}`;
|
|
99
|
-
// Adjust the lastIndex to avoid passing over the next link if the
|
|
100
|
-
// newly replaced URL is shorter.
|
|
101
|
-
linkPattern.lastIndex += encodedPermalink.length - mdLink.length;
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
const brokenMarkdownLink = {
|
|
105
|
-
contentPaths,
|
|
106
|
-
filePath,
|
|
107
|
-
link: mdLink,
|
|
108
|
-
};
|
|
109
|
-
brokenMarkdownLinks.push(brokenMarkdownLink);
|
|
110
|
-
}
|
|
111
|
-
mdMatch = linkPattern.exec(modifiedLine);
|
|
112
|
-
}
|
|
113
|
-
return modifiedLine;
|
|
114
|
-
});
|
|
115
|
-
const newContent = lines.join('\n');
|
|
116
|
-
return { newContent, brokenMarkdownLinks };
|
|
24
|
+
// /file.md is never relative to the source file path
|
|
25
|
+
if (!linkPathname.startsWith('/')) {
|
|
26
|
+
sourceDirsToTry.push(path_1.default.dirname(sourceFilePath));
|
|
27
|
+
}
|
|
28
|
+
const aliasedSourceMatch = sourceDirsToTry
|
|
29
|
+
.map((sourceDir) => path_1.default.join(sourceDir, decodeURIComponent(linkPathname)))
|
|
30
|
+
.map((source) => (0, pathUtils_1.aliasedSitePath)(source, siteDir))
|
|
31
|
+
.find((source) => sourceToPermalink.has(source));
|
|
32
|
+
return aliasedSourceMatch
|
|
33
|
+
? sourceToPermalink.get(aliasedSourceMatch) ?? null
|
|
34
|
+
: null;
|
|
117
35
|
}
|
|
118
|
-
exports.
|
|
36
|
+
exports.resolveMarkdownLinkPathname = resolveMarkdownLinkPathname;
|
|
119
37
|
//# sourceMappingURL=markdownLinks.js.map
|
package/lib/markdownLinks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownLinks.js","sourceRoot":"","sources":["../src/markdownLinks.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,wDAAwB;AACxB,mDAAmD;AACnD,2CAA4C;
|
|
1
|
+
{"version":3,"file":"markdownLinks.js","sourceRoot":"","sources":["../src/markdownLinks.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,wDAAwB;AACxB,mDAAmD;AACnD,2CAA4C;AAsC5C,iEAAiE;AACjE,mEAAmE;AACnE,6DAA6D;AAC7D,SAAgB,2BAA2B,CACzC,YAAoB,EACpB,OAKC;IAED,MAAM,EAAC,cAAc,EAAE,iBAAiB,EAAE,YAAY,EAAE,OAAO,EAAC,GAAG,OAAO,CAAC;IAC3E,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,mEAAmE;IACnE,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACtE,eAAe,CAAC,IAAI,CAAC,GAAG,IAAA,kCAAkB,EAAC,YAAY,CAAC,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC;IACD,qDAAqD;IACrD,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAClC,eAAe,CAAC,IAAI,CAAC,cAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,kBAAkB,GAAG,eAAe;SACvC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC;SAC1E,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAA,2BAAe,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;SACjD,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IAEnD,OAAO,kBAAkB;QACvB,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,IAAI;QACnD,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AA5BD,kEA4BC"}
|
package/lib/tags.d.ts
CHANGED
|
@@ -4,11 +4,25 @@
|
|
|
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
|
-
|
|
7
|
+
import type { Optional } from 'utility-types';
|
|
8
8
|
export type Tag = {
|
|
9
|
+
/** The display label of a tag */
|
|
9
10
|
label: string;
|
|
10
11
|
/** Permalink to this tag's page, without the `/tags/` base path. */
|
|
11
12
|
permalink: string;
|
|
13
|
+
/** An optional description of the tag */
|
|
14
|
+
description: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
export type TagsFileInput = Record<string, Partial<Tag> | null>;
|
|
17
|
+
export type TagsFile = Record<string, Tag>;
|
|
18
|
+
export type TagsPluginOptions = {
|
|
19
|
+
/** Path to the tags file. */
|
|
20
|
+
tags: string | false | null | undefined;
|
|
21
|
+
/** The behavior of Docusaurus when it found inline tags. */
|
|
22
|
+
onInlineTags: 'ignore' | 'log' | 'warn' | 'throw';
|
|
23
|
+
};
|
|
24
|
+
export type TagMetadata = Tag & {
|
|
25
|
+
inline: boolean;
|
|
12
26
|
};
|
|
13
27
|
/** What the tags list page should know about each tag. */
|
|
14
28
|
export type TagsListItem = Tag & {
|
|
@@ -22,23 +36,26 @@ export type TagModule = TagsListItem & {
|
|
|
22
36
|
/** Is this tag unlisted? (when it only contains unlisted items) */
|
|
23
37
|
unlisted: boolean;
|
|
24
38
|
};
|
|
25
|
-
export type FrontMatterTag = string | Tag
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
export type FrontMatterTag = string | Optional<Tag, 'description'>;
|
|
40
|
+
export declare function normalizeTag({ tag, tagsFile, tagsBaseRoutePath, }: {
|
|
41
|
+
tag: FrontMatterTag;
|
|
42
|
+
tagsBaseRoutePath: string;
|
|
43
|
+
tagsFile: TagsFile | null;
|
|
44
|
+
}): TagMetadata;
|
|
45
|
+
export declare function normalizeTags({ options, source, frontMatterTags, tagsBaseRoutePath, tagsFile, }: {
|
|
46
|
+
options: TagsPluginOptions;
|
|
47
|
+
source: string;
|
|
48
|
+
frontMatterTags: FrontMatterTag[] | undefined;
|
|
49
|
+
tagsBaseRoutePath: string;
|
|
50
|
+
tagsFile: TagsFile | null;
|
|
51
|
+
}): TagMetadata[];
|
|
52
|
+
export declare function reportInlineTags({ tags, source, options, }: {
|
|
53
|
+
tags: TagMetadata[];
|
|
54
|
+
source: string;
|
|
55
|
+
options: TagsPluginOptions;
|
|
56
|
+
}): void;
|
|
40
57
|
type TaggedItemGroup<Item> = {
|
|
41
|
-
tag:
|
|
58
|
+
tag: TagMetadata;
|
|
42
59
|
items: Item[];
|
|
43
60
|
};
|
|
44
61
|
/**
|
|
@@ -54,7 +71,7 @@ export declare function groupTaggedItems<Item>(items: readonly Item[],
|
|
|
54
71
|
* A callback telling me how to get the tags list of the current item. Usually
|
|
55
72
|
* simply getting it from some metadata of the current item.
|
|
56
73
|
*/
|
|
57
|
-
getItemTags: (item: Item) => readonly
|
|
74
|
+
getItemTags: (item: Item) => readonly TagMetadata[]): {
|
|
58
75
|
[permalink: string]: TaggedItemGroup<Item>;
|
|
59
76
|
};
|
|
60
77
|
/**
|
package/lib/tags.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,
|
|
1
|
+
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAE5C,MAAM,MAAM,GAAG,GAAG;IAChB,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;AAEhE,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAG3C,MAAM,MAAM,iBAAiB,GAAG;IAE9B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,4DAA4D;IAC5D,YAAY,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,GAAG,GAAG;IAC9B,MAAM,EAAE,OAAO,CA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OG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EACnC,KAAK,EAAE,SAAS,IAAI,EAAE;AACtB;;;GAGG;AACH,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,SAAS,WAAW,EAAE,GAClD;IAAC,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAA;CAAC,CA0B9C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,EACrC,KAAK,EACL,UAAU,GACX,EAAE;IACD,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;CACrC,GAAG;IACF,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,IAAI,EAAE,CAAC;CACrB,CAaA"}
|
package/lib/tags.js
CHANGED
|
@@ -6,50 +6,79 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.getTagVisibility = exports.groupTaggedItems = exports.
|
|
9
|
+
exports.getTagVisibility = exports.groupTaggedItems = exports.reportInlineTags = exports.normalizeTags = exports.normalizeTag = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
12
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
12
13
|
const urlUtils_1 = require("./urlUtils");
|
|
13
|
-
|
|
14
|
+
// We always apply tagsBaseRoutePath on purpose. For versioned docs, v1/doc.md
|
|
15
|
+
// and v2/doc.md tags with custom permalinks don't lead to the same created
|
|
16
|
+
// page. tagsBaseRoutePath is different for each doc version
|
|
17
|
+
function normalizeTagPermalink({ tagsBaseRoutePath, permalink, }) {
|
|
18
|
+
return (0, urlUtils_1.normalizeUrl)([tagsBaseRoutePath, permalink]);
|
|
19
|
+
}
|
|
20
|
+
function normalizeInlineTag(tagsBaseRoutePath, frontMatterTag) {
|
|
14
21
|
function toTagObject(tagString) {
|
|
15
22
|
return {
|
|
23
|
+
inline: true,
|
|
16
24
|
label: tagString,
|
|
17
25
|
permalink: lodash_1.default.kebabCase(tagString),
|
|
26
|
+
description: undefined,
|
|
18
27
|
};
|
|
19
28
|
}
|
|
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
29
|
const tag = typeof frontMatterTag === 'string'
|
|
28
30
|
? toTagObject(frontMatterTag)
|
|
29
|
-
: frontMatterTag;
|
|
31
|
+
: { ...frontMatterTag, description: frontMatterTag.description };
|
|
30
32
|
return {
|
|
33
|
+
inline: true,
|
|
31
34
|
label: tag.label,
|
|
32
|
-
permalink: normalizeTagPermalink(
|
|
35
|
+
permalink: normalizeTagPermalink({
|
|
36
|
+
permalink: tag.permalink,
|
|
37
|
+
tagsBaseRoutePath,
|
|
38
|
+
}),
|
|
39
|
+
description: tag.description,
|
|
33
40
|
};
|
|
34
41
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
function normalizeTag({ tag, tagsFile, tagsBaseRoutePath, }) {
|
|
43
|
+
if (typeof tag === 'string') {
|
|
44
|
+
const tagDescription = tagsFile?.[tag];
|
|
45
|
+
if (tagDescription) {
|
|
46
|
+
// pre-defined tag from tags.yml
|
|
47
|
+
return {
|
|
48
|
+
inline: false,
|
|
49
|
+
label: tagDescription.label,
|
|
50
|
+
permalink: normalizeTagPermalink({
|
|
51
|
+
permalink: tagDescription.permalink,
|
|
52
|
+
tagsBaseRoutePath,
|
|
53
|
+
}),
|
|
54
|
+
description: tagDescription.description,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// legacy inline tag object, always inline, unknown because isn't a string
|
|
59
|
+
return normalizeInlineTag(tagsBaseRoutePath, tag);
|
|
60
|
+
}
|
|
61
|
+
exports.normalizeTag = normalizeTag;
|
|
62
|
+
function normalizeTags({ options, source, frontMatterTags, tagsBaseRoutePath, tagsFile, }) {
|
|
63
|
+
const tags = (frontMatterTags ?? []).map((tag) => normalizeTag({ tag, tagsBaseRoutePath, tagsFile }));
|
|
64
|
+
if (tagsFile !== null) {
|
|
65
|
+
reportInlineTags({ tags, source, options });
|
|
66
|
+
}
|
|
67
|
+
return tags;
|
|
68
|
+
}
|
|
69
|
+
exports.normalizeTags = normalizeTags;
|
|
70
|
+
function reportInlineTags({ tags, source, options, }) {
|
|
71
|
+
if (options.onInlineTags === 'ignore') {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const inlineTags = tags.filter((tag) => tag.inline);
|
|
75
|
+
if (inlineTags.length > 0) {
|
|
76
|
+
const uniqueUnknownTags = [...new Set(inlineTags.map((tag) => tag.label))];
|
|
77
|
+
const tagListString = uniqueUnknownTags.join(', ');
|
|
78
|
+
logger_1.default.report(options.onInlineTags)(`Tags [${tagListString}] used in ${source} are not defined in ${options.tags ?? 'tags.yml'}`);
|
|
79
|
+
}
|
|
51
80
|
}
|
|
52
|
-
exports.
|
|
81
|
+
exports.reportInlineTags = reportInlineTags;
|
|
53
82
|
/**
|
|
54
83
|
* Permits to group docs/blog posts by tag (provided by front matter).
|
|
55
84
|
*
|
package/lib/tags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../src/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BAAgB,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACjD,iEAAiE;IACjE,uDAAuD;IACvD,IAAI,gBAAgB,EAAE,CAAC;QACrB,OAAO,EAAC,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAC,CAAC;IAC9C,CAAC;IACD,2DAA2D;IAC3D,mCAAmC;IACnC,OAAO;QACL,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;KACvD,CAAC;AACJ,CAAC;AAtBD,4CAsBC"}
|
package/lib/urlUtils.d.ts
CHANGED
|
@@ -41,12 +41,26 @@ export declare function encodePath(userPath: string): string;
|
|
|
41
41
|
* special characters.
|
|
42
42
|
*/
|
|
43
43
|
export declare function isValidPathname(str: string): boolean;
|
|
44
|
+
export declare function parseURLOrPath(url: string, base?: string | URL): URL;
|
|
44
45
|
export type URLPath = {
|
|
45
46
|
pathname: string;
|
|
46
47
|
search?: string;
|
|
47
48
|
hash?: string;
|
|
48
49
|
};
|
|
50
|
+
export declare function toURLPath(url: URL): URLPath;
|
|
51
|
+
/**
|
|
52
|
+
* Let's name the concept of (pathname + search + hash) as URLPath
|
|
53
|
+
* See also https://twitter.com/kettanaito/status/1741768992866308120
|
|
54
|
+
* Note: this function also resolves relative pathnames while parsing!
|
|
55
|
+
*/
|
|
49
56
|
export declare function parseURLPath(urlPath: string, fromPath?: string): URLPath;
|
|
57
|
+
/**
|
|
58
|
+
* This returns results for strings like "foo", "../foo", "./foo.mdx?qs#hash"
|
|
59
|
+
* Unlike "parseURLPath()" above, this will not resolve the pathnames
|
|
60
|
+
* Te returned pathname of "../../foo.mdx" will be "../../foo.mdx", not "/foo"
|
|
61
|
+
* This returns null if the url is not "local" (contains domain/protocol etc)
|
|
62
|
+
*/
|
|
63
|
+
export declare function parseLocalURLPath(urlPath: string): URLPath | null;
|
|
50
64
|
export declare function serializeURLPath(urlPath: URLPath): string;
|
|
51
65
|
/**
|
|
52
66
|
* Resolve pathnames and fail-fast if resolution fails. Uses standard URL
|