@docusaurus/utils 0.0.0-5957 → 0.0.0-5962
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -3
- package/lib/index.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/package.json +6 -5
- package/src/index.ts +6 -1
- package/src/tags.ts +121 -36
package/lib/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { mergeTranslations, updateTranslationFileMessages, getPluginI18nPath, lo
|
|
|
11
11
|
export { mapAsyncSequential, findAsyncSequential } from './jsUtils';
|
|
12
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
16
|
export { type ContentPaths, resolveMarkdownLinkPathname } from './markdownLinks';
|
|
17
17
|
export { type SluggerOptions, type Slugger, createSlugger } from './slugger';
|
|
@@ -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,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,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,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,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,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,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,+BAA+B,EAC/B,aAAa,EACb,0BAA0B,EAC1B,yBAAyB,EACzB,iBAAi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HANGED
|
@@ -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.DEFAULT_PARSE_FRONT_MATTER = exports.createExcerpt = exports.admonitionTitleToDirectiveLabel = exports.unwrapMdxCodeBlocks = exports.escapeMarkdownHeadingIds = exports.parseMarkdownHeadingId = exports.getTagVisibility = exports.groupTaggedItems = 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.resolveMarkdownLinkPathname = exports.writeMarkdownHeadingId = exports.parseMarkdownFile =
|
|
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; } });
|
|
@@ -56,7 +56,6 @@ Object.defineProperty(exports, "hasSSHProtocol", { enumerable: true, get: functi
|
|
|
56
56
|
Object.defineProperty(exports, "buildHttpsUrl", { enumerable: true, get: function () { return urlUtils_1.buildHttpsUrl; } });
|
|
57
57
|
Object.defineProperty(exports, "buildSshUrl", { enumerable: true, get: function () { return urlUtils_1.buildSshUrl; } });
|
|
58
58
|
var tags_1 = require("./tags");
|
|
59
|
-
Object.defineProperty(exports, "normalizeFrontMatterTags", { enumerable: true, get: function () { return tags_1.normalizeFrontMatterTags; } });
|
|
60
59
|
Object.defineProperty(exports, "groupTaggedItems", { enumerable: true, get: function () { return tags_1.groupTaggedItems; } });
|
|
61
60
|
Object.defineProperty(exports, "getTagVisibility", { enumerable: true, get: function () { return tags_1.getTagVisibility; } });
|
|
62
61
|
var markdownUtils_1 = require("./markdownUtils");
|
|
@@ -118,4 +117,7 @@ Object.defineProperty(exports, "getGitLastUpdate", { enumerable: true, get: func
|
|
|
118
117
|
Object.defineProperty(exports, "getLastUpdate", { enumerable: true, get: function () { return lastUpdateUtils_1.getLastUpdate; } });
|
|
119
118
|
Object.defineProperty(exports, "readLastUpdateData", { enumerable: true, get: function () { return lastUpdateUtils_1.readLastUpdateData; } });
|
|
120
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; } });
|
|
121
123
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.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ArD,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/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,CAAC;CACjB,CAAC;AAEF,0DAA0D;AAC1D,MAAM,MAAM,YAAY,GAAG,GAAG,GAAG;IAC/B,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,yDAAyD;AACzD,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG;IACrC,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;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AE,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/tags.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,4DAAuB;AACvB,yCAAwC;
|
|
1
|
+
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../src/tags.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,4DAAuB;AACvB,wEAAwC;AACxC,yCAAwC;AA6CxC,8EAA8E;AAC9E,2EAA2E;AAC3E,4DAA4D;AAC5D,SAAS,qBAAqB,CAAC,EAC7B,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,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;KACvD,CAAC;AACJ,CAAC;AAtBD,4CAsBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/utils",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-5962",
|
|
4
4
|
"description": "Node utility functions for Docusaurus packages.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/logger": "0.0.0-
|
|
22
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
21
|
+
"@docusaurus/logger": "0.0.0-5962",
|
|
22
|
+
"@docusaurus/utils-common": "0.0.0-5962",
|
|
23
23
|
"@svgr/webpack": "^8.1.0",
|
|
24
24
|
"escape-string-regexp": "^4.0.0",
|
|
25
25
|
"file-loader": "^6.2.0",
|
|
@@ -36,13 +36,14 @@
|
|
|
36
36
|
"shelljs": "^0.8.5",
|
|
37
37
|
"tslib": "^2.6.0",
|
|
38
38
|
"url-loader": "^4.1.1",
|
|
39
|
+
"utility-types": "^3.10.0",
|
|
39
40
|
"webpack": "^5.88.1"
|
|
40
41
|
},
|
|
41
42
|
"engines": {
|
|
42
43
|
"node": ">=18.0"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"@docusaurus/types": "0.0.0-
|
|
46
|
+
"@docusaurus/types": "0.0.0-5962",
|
|
46
47
|
"@types/dedent": "^0.7.0",
|
|
47
48
|
"@types/github-slugger": "^1.3.0",
|
|
48
49
|
"@types/micromatch": "^4.0.2",
|
|
@@ -58,5 +59,5 @@
|
|
|
58
59
|
"optional": true
|
|
59
60
|
}
|
|
60
61
|
},
|
|
61
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "35386a1d384d8e8757ef9f993b84dd5accc00e97"
|
|
62
63
|
}
|
package/src/index.ts
CHANGED
|
@@ -55,10 +55,13 @@ export {
|
|
|
55
55
|
export type {URLPath} from './urlUtils';
|
|
56
56
|
export {
|
|
57
57
|
type Tag,
|
|
58
|
+
type TagsFile,
|
|
59
|
+
type TagsFileInput,
|
|
60
|
+
type TagMetadata,
|
|
58
61
|
type TagsListItem,
|
|
59
62
|
type TagModule,
|
|
60
63
|
type FrontMatterTag,
|
|
61
|
-
|
|
64
|
+
type TagsPluginOptions,
|
|
62
65
|
groupTaggedItems,
|
|
63
66
|
getTagVisibility,
|
|
64
67
|
} from './tags';
|
|
@@ -120,3 +123,5 @@ export {
|
|
|
120
123
|
type LastUpdateData,
|
|
121
124
|
type FrontMatterLastUpdate,
|
|
122
125
|
} from './lastUpdateUtils';
|
|
126
|
+
|
|
127
|
+
export {normalizeTags, reportInlineTags} from './tags';
|
package/src/tags.ts
CHANGED
|
@@ -6,13 +6,34 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import _ from 'lodash';
|
|
9
|
+
import logger from '@docusaurus/logger';
|
|
9
10
|
import {normalizeUrl} from './urlUtils';
|
|
11
|
+
import type {Optional} from 'utility-types';
|
|
10
12
|
|
|
11
|
-
/** What the user configures. */
|
|
12
13
|
export type Tag = {
|
|
14
|
+
/** The display label of a tag */
|
|
13
15
|
label: string;
|
|
14
16
|
/** Permalink to this tag's page, without the `/tags/` base path. */
|
|
15
17
|
permalink: string;
|
|
18
|
+
/** An optional description of the tag */
|
|
19
|
+
description: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type TagsFileInput = Record<string, Partial<Tag> | null>;
|
|
23
|
+
|
|
24
|
+
export type TagsFile = Record<string, Tag>;
|
|
25
|
+
|
|
26
|
+
// Tags plugins options shared between docs/blog
|
|
27
|
+
export type TagsPluginOptions = {
|
|
28
|
+
// TODO allow option tags later? | TagsFile;
|
|
29
|
+
/** Path to the tags file. */
|
|
30
|
+
tags: string | false | null | undefined;
|
|
31
|
+
/** The behavior of Docusaurus when it found inline tags. */
|
|
32
|
+
onInlineTags: 'ignore' | 'log' | 'warn' | 'throw';
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type TagMetadata = Tag & {
|
|
36
|
+
inline: boolean;
|
|
16
37
|
};
|
|
17
38
|
|
|
18
39
|
/** What the tags list page should know about each tag. */
|
|
@@ -29,62 +50,126 @@ export type TagModule = TagsListItem & {
|
|
|
29
50
|
unlisted: boolean;
|
|
30
51
|
};
|
|
31
52
|
|
|
32
|
-
export type FrontMatterTag = string | Tag
|
|
53
|
+
export type FrontMatterTag = string | Optional<Tag, 'description'>;
|
|
33
54
|
|
|
34
|
-
|
|
35
|
-
|
|
55
|
+
// We always apply tagsBaseRoutePath on purpose. For versioned docs, v1/doc.md
|
|
56
|
+
// and v2/doc.md tags with custom permalinks don't lead to the same created
|
|
57
|
+
// page. tagsBaseRoutePath is different for each doc version
|
|
58
|
+
function normalizeTagPermalink({
|
|
59
|
+
tagsBaseRoutePath,
|
|
60
|
+
permalink,
|
|
61
|
+
}: {
|
|
62
|
+
tagsBaseRoutePath: string;
|
|
63
|
+
permalink: string;
|
|
64
|
+
}): string {
|
|
65
|
+
return normalizeUrl([tagsBaseRoutePath, permalink]);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function normalizeInlineTag(
|
|
69
|
+
tagsBaseRoutePath: string,
|
|
36
70
|
frontMatterTag: FrontMatterTag,
|
|
37
|
-
):
|
|
38
|
-
function toTagObject(tagString: string):
|
|
71
|
+
): TagMetadata {
|
|
72
|
+
function toTagObject(tagString: string): TagMetadata {
|
|
39
73
|
return {
|
|
74
|
+
inline: true,
|
|
40
75
|
label: tagString,
|
|
41
76
|
permalink: _.kebabCase(tagString),
|
|
77
|
+
description: undefined,
|
|
42
78
|
};
|
|
43
79
|
}
|
|
44
80
|
|
|
45
|
-
// TODO maybe make ensure the permalink is valid url path?
|
|
46
|
-
function normalizeTagPermalink(permalink: string): string {
|
|
47
|
-
// Note: we always apply tagsPath on purpose. For versioned docs, v1/doc.md
|
|
48
|
-
// and v2/doc.md tags with custom permalinks don't lead to the same created
|
|
49
|
-
// page. tagsPath is different for each doc version
|
|
50
|
-
return normalizeUrl([tagsPath, permalink]);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
81
|
const tag: Tag =
|
|
54
82
|
typeof frontMatterTag === 'string'
|
|
55
83
|
? toTagObject(frontMatterTag)
|
|
56
|
-
: frontMatterTag;
|
|
84
|
+
: {...frontMatterTag, description: frontMatterTag.description};
|
|
57
85
|
|
|
58
86
|
return {
|
|
87
|
+
inline: true,
|
|
59
88
|
label: tag.label,
|
|
60
|
-
permalink: normalizeTagPermalink(
|
|
89
|
+
permalink: normalizeTagPermalink({
|
|
90
|
+
permalink: tag.permalink,
|
|
91
|
+
tagsBaseRoutePath,
|
|
92
|
+
}),
|
|
93
|
+
description: tag.description,
|
|
61
94
|
};
|
|
62
95
|
}
|
|
63
96
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
97
|
+
export function normalizeTag({
|
|
98
|
+
tag,
|
|
99
|
+
tagsFile,
|
|
100
|
+
tagsBaseRoutePath,
|
|
101
|
+
}: {
|
|
102
|
+
tag: FrontMatterTag;
|
|
103
|
+
tagsBaseRoutePath: string;
|
|
104
|
+
tagsFile: TagsFile | null;
|
|
105
|
+
}): TagMetadata {
|
|
106
|
+
if (typeof tag === 'string') {
|
|
107
|
+
const tagDescription = tagsFile?.[tag];
|
|
108
|
+
if (tagDescription) {
|
|
109
|
+
// pre-defined tag from tags.yml
|
|
110
|
+
return {
|
|
111
|
+
inline: false,
|
|
112
|
+
label: tagDescription.label,
|
|
113
|
+
permalink: normalizeTagPermalink({
|
|
114
|
+
permalink: tagDescription.permalink,
|
|
115
|
+
tagsBaseRoutePath,
|
|
116
|
+
}),
|
|
117
|
+
description: tagDescription.description,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// legacy inline tag object, always inline, unknown because isn't a string
|
|
122
|
+
return normalizeInlineTag(tagsBaseRoutePath, tag);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function normalizeTags({
|
|
126
|
+
options,
|
|
127
|
+
source,
|
|
128
|
+
frontMatterTags,
|
|
129
|
+
tagsBaseRoutePath,
|
|
130
|
+
tagsFile,
|
|
131
|
+
}: {
|
|
132
|
+
options: TagsPluginOptions;
|
|
133
|
+
source: string;
|
|
134
|
+
frontMatterTags: FrontMatterTag[] | undefined;
|
|
135
|
+
tagsBaseRoutePath: string;
|
|
136
|
+
tagsFile: TagsFile | null;
|
|
137
|
+
}): TagMetadata[] {
|
|
138
|
+
const tags = (frontMatterTags ?? []).map((tag) =>
|
|
139
|
+
normalizeTag({tag, tagsBaseRoutePath, tagsFile}),
|
|
81
140
|
);
|
|
141
|
+
if (tagsFile !== null) {
|
|
142
|
+
reportInlineTags({tags, source, options});
|
|
143
|
+
}
|
|
144
|
+
return tags;
|
|
145
|
+
}
|
|
82
146
|
|
|
83
|
-
|
|
147
|
+
export function reportInlineTags({
|
|
148
|
+
tags,
|
|
149
|
+
source,
|
|
150
|
+
options,
|
|
151
|
+
}: {
|
|
152
|
+
tags: TagMetadata[];
|
|
153
|
+
source: string;
|
|
154
|
+
options: TagsPluginOptions;
|
|
155
|
+
}): void {
|
|
156
|
+
if (options.onInlineTags === 'ignore') {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const inlineTags = tags.filter((tag) => tag.inline);
|
|
160
|
+
if (inlineTags.length > 0) {
|
|
161
|
+
const uniqueUnknownTags = [...new Set(inlineTags.map((tag) => tag.label))];
|
|
162
|
+
const tagListString = uniqueUnknownTags.join(', ');
|
|
163
|
+
logger.report(options.onInlineTags)(
|
|
164
|
+
`Tags [${tagListString}] used in ${source} are not defined in ${
|
|
165
|
+
options.tags ?? 'tags.yml'
|
|
166
|
+
}`,
|
|
167
|
+
);
|
|
168
|
+
}
|
|
84
169
|
}
|
|
85
170
|
|
|
86
171
|
type TaggedItemGroup<Item> = {
|
|
87
|
-
tag:
|
|
172
|
+
tag: TagMetadata;
|
|
88
173
|
items: Item[];
|
|
89
174
|
};
|
|
90
175
|
|
|
@@ -102,7 +187,7 @@ export function groupTaggedItems<Item>(
|
|
|
102
187
|
* A callback telling me how to get the tags list of the current item. Usually
|
|
103
188
|
* simply getting it from some metadata of the current item.
|
|
104
189
|
*/
|
|
105
|
-
getItemTags: (item: Item) => readonly
|
|
190
|
+
getItemTags: (item: Item) => readonly TagMetadata[],
|
|
106
191
|
): {[permalink: string]: TaggedItemGroup<Item>} {
|
|
107
192
|
const result: {[permalink: string]: TaggedItemGroup<Item>} = {};
|
|
108
193
|
|