@docusaurus/plugin-content-docs 0.0.0-4644 → 0.0.0-4645

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.
@@ -10,13 +10,12 @@ exports.getCategoryGeneratedIndexMetadataList = void 0;
10
10
  const utils_1 = require("./sidebars/utils");
11
11
  const docs_1 = require("./docs");
12
12
  function getCategoryGeneratedIndexMetadata({ category, sidebarsUtils, docsById, }) {
13
- var _a;
14
13
  const { sidebarName, previous, next } = sidebarsUtils.getCategoryGeneratedIndexNavigation(category.link.permalink);
15
14
  if (!sidebarName) {
16
15
  throw new Error('unexpected');
17
16
  }
18
17
  return {
19
- title: (_a = category.link.title) !== null && _a !== void 0 ? _a : category.label,
18
+ title: category.link.title ?? category.label,
20
19
  description: category.link.description,
21
20
  image: category.link.image,
22
21
  keywords: category.link.keywords,
package/lib/cli.js CHANGED
@@ -9,11 +9,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.cliDocsVersionCommand = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const versions_1 = require("./versions");
12
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
12
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
+ const path_1 = tslib_1.__importDefault(require("path"));
14
14
  const sidebars_1 = require("./sidebars");
15
15
  const utils_1 = require("@docusaurus/utils");
16
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
16
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
17
17
  async function createVersionedSidebarFile({ siteDir, pluginId, sidebarPath, version, }) {
18
18
  // Load current sidebar and create a new versioned sidebars file (if needed).
19
19
  // Note: we don't need the sidebars file to be normalized: it's ok to let
@@ -53,7 +53,7 @@ const getActiveVersion = (data, pathname) => {
53
53
  exports.getActiveVersion = getActiveVersion;
54
54
  const getActiveDocContext = (data, pathname) => {
55
55
  const activeVersion = (0, exports.getActiveVersion)(data, pathname);
56
- const activeDoc = activeVersion === null || activeVersion === void 0 ? void 0 : activeVersion.docs.find((doc) => !!(0, router_1.matchPath)(pathname, {
56
+ const activeDoc = activeVersion?.docs.find((doc) => !!(0, router_1.matchPath)(pathname, {
57
57
  path: doc.path,
58
58
  exact: true,
59
59
  strict: false,
@@ -82,7 +82,7 @@ exports.getActiveDocContext = getActiveDocContext;
82
82
  const getDocVersionSuggestions = (data, pathname) => {
83
83
  const latestVersion = (0, exports.getLatestVersion)(data);
84
84
  const activeDocContext = (0, exports.getActiveDocContext)(data, pathname);
85
- const latestDocSuggestion = activeDocContext === null || activeDocContext === void 0 ? void 0 : activeDocContext.alternateDocVersions[latestVersion.name];
85
+ const latestDocSuggestion = activeDocContext?.alternateDocVersions[latestVersion.name];
86
86
  return { latestDocSuggestion, latestVersionSuggestion: latestVersion };
87
87
  };
88
88
  exports.getDocVersionSuggestions = getDocVersionSuggestions;
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.useDocVersionSuggestions = exports.useActiveDocContext = exports.useActiveVersion = exports.useLatestVersion = exports.useVersions = exports.useActivePluginAndVersion = exports.useActivePlugin = exports.useDocsData = exports.useAllDocsData = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const router_1 = require("@docusaurus/router");
12
- const useGlobalData_1 = (0, tslib_1.__importStar)(require("@docusaurus/useGlobalData"));
12
+ const useGlobalData_1 = tslib_1.__importStar(require("@docusaurus/useGlobalData"));
13
13
  const docsClientUtils_1 = require("./docsClientUtils");
14
14
  // Important to use a constant object to avoid React useEffect executions etc.
15
15
  // see https://github.com/facebook/docusaurus/issues/5089
@@ -17,7 +17,7 @@ const StableEmptyObject = {};
17
17
  // Not using useAllPluginInstancesData() because in blog-only mode, docs hooks
18
18
  // are still used by the theme. We need a fail-safe fallback when the docs
19
19
  // plugin is not in use
20
- const useAllDocsData = () => { var _a; return (_a = (0, useGlobalData_1.default)()['docusaurus-plugin-content-docs']) !== null && _a !== void 0 ? _a : StableEmptyObject; };
20
+ const useAllDocsData = () => (0, useGlobalData_1.default)()['docusaurus-plugin-content-docs'] ?? StableEmptyObject;
21
21
  exports.useAllDocsData = useAllDocsData;
22
22
  const useDocsData = (pluginId) => (0, useGlobalData_1.usePluginData)('docusaurus-plugin-content-docs', pluginId);
23
23
  exports.useDocsData = useDocsData;
package/lib/docs.js CHANGED
@@ -8,12 +8,12 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.createDocsByIdIndex = exports.getDocIds = exports.splitPath = exports.toCategoryIndexMatcherParam = exports.isCategoryIndex = exports.getMainDocId = exports.addDocNavigation = exports.processDocMetadata = exports.readVersionDocs = exports.readDocFile = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
12
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
13
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
11
+ const path_1 = tslib_1.__importDefault(require("path"));
12
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
14
  const utils_1 = require("@docusaurus/utils");
15
15
  const lastUpdate_1 = require("./lastUpdate");
16
- const slug_1 = (0, tslib_1.__importDefault)(require("./slug"));
16
+ const slug_1 = tslib_1.__importDefault(require("./slug"));
17
17
  const constants_1 = require("./constants");
18
18
  const versions_1 = require("./versions");
19
19
  const numberPrefix_1 = require("./numberPrefix");
@@ -58,7 +58,6 @@ async function readVersionDocs(versionMetadata, options) {
58
58
  }
59
59
  exports.readVersionDocs = readVersionDocs;
60
60
  function doProcessDocMetadata({ docFile, versionMetadata, context, options, }) {
61
- var _a, _b, _c, _d, _e, _f;
62
61
  const { source, content, lastUpdate, contentPath, filePath } = docFile;
63
62
  const { siteDir, i18n } = context;
64
63
  const { frontMatter: unsafeFrontMatter, contentTitle, excerpt, } = (0, utils_1.parseMarkdownString)(content);
@@ -77,13 +76,13 @@ function doProcessDocMetadata({ docFile, versionMetadata, context, options, }) {
77
76
  const { filename: unprefixedFileName, numberPrefix } = parseNumberPrefixes
78
77
  ? options.numberPrefixParser(sourceFileNameWithoutExtension)
79
78
  : { filename: sourceFileNameWithoutExtension, numberPrefix: undefined };
80
- const baseID = (_a = frontMatter.id) !== null && _a !== void 0 ? _a : unprefixedFileName;
79
+ const baseID = frontMatter.id ?? unprefixedFileName;
81
80
  if (baseID.includes('/')) {
82
81
  throw new Error(`Document id "${baseID}" cannot include slash.`);
83
82
  }
84
83
  // For autogenerated sidebars, sidebar position can come from filename number
85
84
  // prefix or front matter
86
- const sidebarPosition = (_b = frontMatter.sidebar_position) !== null && _b !== void 0 ? _b : numberPrefix;
85
+ const sidebarPosition = frontMatter.sidebar_position ?? numberPrefix;
87
86
  // TODO legacy retrocompatibility
88
87
  // The same doc in 2 distinct version could keep the same id,
89
88
  // we just need to namespace the data by version
@@ -118,8 +117,8 @@ function doProcessDocMetadata({ docFile, versionMetadata, context, options, }) {
118
117
  // Note: the title is used by default for page title, sidebar label,
119
118
  // pagination buttons... frontMatter.title should be used in priority over
120
119
  // contentTitle (because it can contain markdown/JSX syntax)
121
- const title = (_d = (_c = frontMatter.title) !== null && _c !== void 0 ? _c : contentTitle) !== null && _d !== void 0 ? _d : baseID;
122
- const description = (_f = (_e = frontMatter.description) !== null && _e !== void 0 ? _e : excerpt) !== null && _f !== void 0 ? _f : '';
120
+ const title = frontMatter.title ?? contentTitle ?? baseID;
121
+ const description = frontMatter.description ?? excerpt ?? '';
123
122
  const permalink = (0, utils_1.normalizeUrl)([versionMetadata.versionPath, docSlug]);
124
123
  function getDocEditUrl() {
125
124
  const relativeFilePath = path_1.default.relative(contentPath, filePath);
@@ -241,11 +240,10 @@ exports.getMainDocId = getMainDocId;
241
240
  // - Slugs do not end with a weird "/index" suffix
242
241
  // - Auto-generated sidebar categories link to them as intro
243
242
  const isCategoryIndex = ({ fileName, directories, }) => {
244
- var _a;
245
243
  const eligibleDocIndexNames = [
246
244
  'index',
247
245
  'readme',
248
- (_a = directories[0]) === null || _a === void 0 ? void 0 : _a.toLowerCase(),
246
+ directories[0]?.toLowerCase(),
249
247
  ];
250
248
  return eligibleDocIndexNames.includes(fileName.toLowerCase());
251
249
  };
package/lib/globalData.js CHANGED
@@ -8,7 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.toGlobalDataVersion = exports.toGlobalSidebars = exports.toGlobalDataGeneratedIndex = exports.toGlobalDataDoc = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
11
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
12
12
  const utils_1 = require("@docusaurus/utils");
13
13
  const utils_2 = require("./sidebars/utils");
14
14
  function toGlobalDataDoc(doc) {
package/lib/index.js CHANGED
@@ -8,7 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.validateOptions = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
11
+ const path_1 = tslib_1.__importDefault(require("path"));
12
12
  const utils_1 = require("@docusaurus/utils");
13
13
  const sidebars_1 = require("./sidebars");
14
14
  const generator_1 = require("./sidebars/generator");
@@ -19,16 +19,15 @@ const constants_1 = require("./constants");
19
19
  const globalData_1 = require("./globalData");
20
20
  const props_1 = require("./props");
21
21
  const translations_1 = require("./translations");
22
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
22
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
23
23
  const tags_1 = require("./tags");
24
24
  const routes_1 = require("./routes");
25
25
  const utils_2 = require("./sidebars/utils");
26
26
  const categoryGeneratedIndex_1 = require("./categoryGeneratedIndex");
27
27
  async function pluginContentDocs(context, options) {
28
- var _a;
29
28
  const { siteDir, generatedFilesDir, baseUrl, siteConfig } = context;
30
29
  const versionsMetadata = await (0, versions_1.readVersionsMetadata)({ context, options });
31
- const pluginId = (_a = options.id) !== null && _a !== void 0 ? _a : utils_1.DEFAULT_PLUGIN_ID;
30
+ const pluginId = options.id ?? utils_1.DEFAULT_PLUGIN_ID;
32
31
  const pluginDataDirRoot = path_1.default.join(generatedFilesDir, 'docusaurus-plugin-content-docs');
33
32
  const dataDir = path_1.default.join(pluginDataDirRoot, pluginId);
34
33
  const aliasedSource = (source) => `~docs/${(0, utils_1.posixPath)(path_1.default.relative(pluginDataDirRoot, source))}`;
package/lib/lastUpdate.js CHANGED
@@ -8,7 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getFileLastUpdate = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
11
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
12
12
  const utils_1 = require("@docusaurus/utils");
13
13
  let showedGitRequirementError = false;
14
14
  async function getFileLastUpdate(filePath) {
@@ -23,13 +23,12 @@ const NumberPrefixRegex = /^(?<numberPrefix>\d+)(?<separator>\s*[-_.]+\s*)(?<suf
23
23
  // 0-myDoc => {filename: myDoc, numberPrefix: 0}
24
24
  // 003 - myDoc => {filename: myDoc, numberPrefix: 3}
25
25
  const DefaultNumberPrefixParser = (filename) => {
26
- var _a, _b, _c;
27
26
  if (IgnoredPrefixPatterns.exec(filename)) {
28
27
  return { filename, numberPrefix: undefined };
29
28
  }
30
29
  const match = NumberPrefixRegex.exec(filename);
31
- const cleanFileName = (_b = (_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.suffix) !== null && _b !== void 0 ? _b : filename;
32
- const numberPrefixString = (_c = match === null || match === void 0 ? void 0 : match.groups) === null || _c === void 0 ? void 0 : _c.numberPrefix;
30
+ const cleanFileName = match?.groups?.suffix ?? filename;
31
+ const numberPrefixString = match?.groups?.numberPrefix;
33
32
  const numberPrefix = numberPrefixString
34
33
  ? parseInt(numberPrefixString, 10)
35
34
  : undefined;
package/lib/options.js CHANGED
@@ -10,8 +10,8 @@ exports.validateOptions = exports.OptionsSchema = exports.DEFAULT_OPTIONS = void
10
10
  const tslib_1 = require("tslib");
11
11
  const utils_validation_1 = require("@docusaurus/utils-validation");
12
12
  const utils_1 = require("@docusaurus/utils");
13
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
14
- const remark_admonitions_1 = (0, tslib_1.__importDefault)(require("remark-admonitions"));
13
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
+ const remark_admonitions_1 = tslib_1.__importDefault(require("remark-admonitions"));
15
15
  const generator_1 = require("./sidebars/generator");
16
16
  const numberPrefix_1 = require("./numberPrefix");
17
17
  exports.DEFAULT_OPTIONS = {
package/lib/props.js CHANGED
@@ -8,7 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.toTagDocListProp = exports.toVersionMetadataProp = exports.toSidebarsProp = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
11
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
12
12
  const docs_1 = require("./docs");
13
13
  function toSidebarsProp(loadedVersion) {
14
14
  const docsById = (0, docs_1.createDocsByIdIndex)(loadedVersion.docs);
@@ -22,7 +22,6 @@ Available document ids are:
22
22
  return docMetadata;
23
23
  }
24
24
  const convertDocLink = (item) => {
25
- var _a;
26
25
  const docMetadata = getDocById(item.id);
27
26
  const { title, permalink, frontMatter: { sidebar_label: sidebarLabel }, } = docMetadata;
28
27
  return {
@@ -30,12 +29,12 @@ Available document ids are:
30
29
  label: sidebarLabel || item.label || title,
31
30
  href: permalink,
32
31
  className: item.className,
33
- customProps: (_a = item.customProps) !== null && _a !== void 0 ? _a : docMetadata.frontMatter.sidebar_custom_props,
32
+ customProps: item.customProps ?? docMetadata.frontMatter.sidebar_custom_props,
34
33
  docId: docMetadata.unversionedId,
35
34
  };
36
35
  };
37
36
  function getCategoryLinkHref(link) {
38
- switch (link === null || link === void 0 ? void 0 : link.type) {
37
+ switch (link?.type) {
39
38
  case 'doc':
40
39
  return getDocById(link.id).permalink;
41
40
  case 'generated-index':
package/lib/routes.js CHANGED
@@ -10,7 +10,7 @@ exports.createVersionRoutes = exports.createDocRoutes = exports.createCategoryGe
10
10
  const tslib_1 = require("tslib");
11
11
  const utils_1 = require("@docusaurus/utils");
12
12
  const props_1 = require("./props");
13
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
13
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
14
  async function createCategoryGeneratedIndexRoutes({ version, actions, docCategoryGeneratedIndexComponent, aliasedSource, }) {
15
15
  const slugs = (0, utils_1.createSlugger)();
16
16
  async function createCategoryGeneratedIndexRoute(categoryGeneratedIndex) {
@@ -8,10 +8,10 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.DefaultSidebarItemsGenerator = exports.CategoryMetadataFilenamePattern = exports.CategoryMetadataFilenameBase = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
11
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
12
12
  const utils_1 = require("@docusaurus/utils");
13
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
14
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
13
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
+ const path_1 = tslib_1.__importDefault(require("path"));
15
15
  const docs_1 = require("../docs");
16
16
  const BreadcrumbSeparator = '/';
17
17
  // To avoid possible name clashes with a folder of the same name as the ID
@@ -101,9 +101,8 @@ const DefaultSidebarItemsGenerator = async ({ numberPrefixParser, isCategoryInde
101
101
  };
102
102
  }
103
103
  async function createCategoryItem(dir, fullPath, folderName) {
104
- var _a, _b;
105
104
  const categoryMetadata = categoriesMetadata[(0, utils_1.posixPath)(path_1.default.join(autogenDir, fullPath))];
106
- const className = categoryMetadata === null || categoryMetadata === void 0 ? void 0 : categoryMetadata.className;
105
+ const className = categoryMetadata?.className;
107
106
  const { filename, numberPrefix } = numberPrefixParser(folderName);
108
107
  const allItems = await Promise.all(Object.entries(dir).map(([key, content]) => dirToItem(content, key, `${fullPath}/${key}`)));
109
108
  // Try to match a doc inside the category folder,
@@ -121,18 +120,17 @@ const DefaultSidebarItemsGenerator = async ({ numberPrefixParser, isCategoryInde
121
120
  });
122
121
  }
123
122
  function getCategoryLinkedDocId() {
124
- var _a, _b;
125
- const link = categoryMetadata === null || categoryMetadata === void 0 ? void 0 : categoryMetadata.link;
123
+ const link = categoryMetadata?.link;
126
124
  if (link !== undefined) {
127
125
  if (link && link.type === 'doc') {
128
- return ((_a = findDocByLocalId(link.id)) === null || _a === void 0 ? void 0 : _a.id) || getDoc(link.id).id;
126
+ return findDocByLocalId(link.id)?.id || getDoc(link.id).id;
129
127
  }
130
128
  // If a link is explicitly specified, we won't apply conventions
131
129
  return undefined;
132
130
  }
133
131
  // Apply default convention to pick index.md, README.md or
134
132
  // <categoryName>.md as the category doc
135
- return (_b = findConventionalCategoryDocLink()) === null || _b === void 0 ? void 0 : _b.id;
133
+ return findConventionalCategoryDocLink()?.id;
136
134
  }
137
135
  const categoryLinkedDocId = getCategoryLinkedDocId();
138
136
  const link = categoryLinkedDocId
@@ -140,15 +138,15 @@ const DefaultSidebarItemsGenerator = async ({ numberPrefixParser, isCategoryInde
140
138
  type: 'doc',
141
139
  id: categoryLinkedDocId, // We "remap" a potentially "local id" to a "qualified id"
142
140
  }
143
- : categoryMetadata === null || categoryMetadata === void 0 ? void 0 : categoryMetadata.link;
141
+ : categoryMetadata?.link;
144
142
  // If a doc is linked, remove it from the category subItems
145
143
  const items = allItems.filter((item) => !(item.type === 'doc' && item.id === categoryLinkedDocId));
146
144
  return {
147
145
  type: 'category',
148
- label: (_a = categoryMetadata === null || categoryMetadata === void 0 ? void 0 : categoryMetadata.label) !== null && _a !== void 0 ? _a : filename,
149
- collapsible: categoryMetadata === null || categoryMetadata === void 0 ? void 0 : categoryMetadata.collapsible,
150
- collapsed: categoryMetadata === null || categoryMetadata === void 0 ? void 0 : categoryMetadata.collapsed,
151
- position: (_b = categoryMetadata === null || categoryMetadata === void 0 ? void 0 : categoryMetadata.position) !== null && _b !== void 0 ? _b : numberPrefix,
146
+ label: categoryMetadata?.label ?? filename,
147
+ collapsible: categoryMetadata?.collapsible,
148
+ collapsed: categoryMetadata?.collapsed,
149
+ position: categoryMetadata?.position ?? numberPrefix,
152
150
  ...(className !== undefined && { className }),
153
151
  items,
154
152
  ...(link && { link }),
@@ -8,18 +8,18 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.loadSidebars = exports.loadSidebarsFileUnsafe = exports.resolveSidebarPathOption = exports.DisabledSidebars = exports.DefaultSidebars = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
12
- const import_fresh_1 = (0, tslib_1.__importDefault)(require("import-fresh"));
11
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
12
+ const import_fresh_1 = tslib_1.__importDefault(require("import-fresh"));
13
13
  const validation_1 = require("./validation");
14
14
  const normalization_1 = require("./normalization");
15
15
  const processor_1 = require("./processor");
16
16
  const postProcessor_1 = require("./postProcessor");
17
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
17
+ const path_1 = tslib_1.__importDefault(require("path"));
18
18
  const utils_1 = require("@docusaurus/utils");
19
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
20
- const js_yaml_1 = (0, tslib_1.__importDefault)(require("js-yaml"));
21
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
22
- const combine_promises_1 = (0, tslib_1.__importDefault)(require("combine-promises"));
19
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
20
+ const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
21
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
22
+ const combine_promises_1 = tslib_1.__importDefault(require("combine-promises"));
23
23
  exports.DefaultSidebars = {
24
24
  defaultSidebar: [
25
25
  {
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.normalizeSidebars = exports.normalizeItem = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const utils_1 = require("./utils");
12
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
13
- const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
12
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
13
+ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
14
14
  function normalizeCategoriesShorthand(sidebar) {
15
15
  return Object.entries(sidebar).map(([label, items]) => ({
16
16
  type: 'category',
@@ -9,13 +9,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.postProcessSidebars = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const utils_1 = require("@docusaurus/utils");
12
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
12
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
13
13
  function normalizeCategoryLink(category, params) {
14
- var _a, _b;
15
- if (((_a = category.link) === null || _a === void 0 ? void 0 : _a.type) === 'generated-index') {
14
+ if (category.link?.type === 'generated-index') {
16
15
  // default slug logic can be improved
17
16
  const getDefaultSlug = () => `/category/${params.categoryLabelSlugger.slug(category.label)}`;
18
- const slug = (_b = category.link.slug) !== null && _b !== void 0 ? _b : getDefaultSlug();
17
+ const slug = category.link.slug ?? getDefaultSlug();
19
18
  const permalink = (0, utils_1.normalizeUrl)([params.version.versionPath, slug]);
20
19
  return {
21
20
  ...category.link,
@@ -26,12 +25,11 @@ function normalizeCategoryLink(category, params) {
26
25
  return category.link;
27
26
  }
28
27
  function postProcessSidebarItem(item, params) {
29
- var _a, _b;
30
28
  if (item.type === 'category') {
31
29
  const category = {
32
30
  ...item,
33
- collapsed: (_a = item.collapsed) !== null && _a !== void 0 ? _a : params.sidebarOptions.sidebarCollapsed,
34
- collapsible: (_b = item.collapsible) !== null && _b !== void 0 ? _b : params.sidebarOptions.sidebarCollapsible,
31
+ collapsed: item.collapsed ?? params.sidebarOptions.sidebarCollapsed,
32
+ collapsible: item.collapsible ?? params.sidebarOptions.sidebarCollapsible,
35
33
  link: normalizeCategoryLink(item, params),
36
34
  items: item.items.map((subItem) => postProcessSidebarItem(subItem, params)),
37
35
  };
@@ -10,8 +10,8 @@ exports.processSidebars = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const generator_1 = require("./generator");
12
12
  const validation_1 = require("./validation");
13
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
14
- const combine_promises_1 = (0, tslib_1.__importDefault)(require("combine-promises"));
13
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
14
+ const combine_promises_1 = tslib_1.__importDefault(require("combine-promises"));
15
15
  const docs_1 = require("../docs");
16
16
  function toSidebarItemsGeneratorDoc(doc) {
17
17
  return lodash_1.default.pick(doc, [
@@ -8,7 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.toNavigationLink = exports.toDocNavigationLink = exports.createSidebarsUtils = exports.collectSidebarsNavigations = exports.collectSidebarsDocIds = exports.collectSidebarNavigation = exports.collectSidebarDocIds = exports.collectSidebarLinks = exports.collectSidebarCategories = exports.collectSidebarDocItems = exports.transformSidebarItems = exports.isCategoriesShorthand = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
11
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
12
12
  const utils_1 = require("@docusaurus/utils");
13
13
  function isCategoriesShorthand(item) {
14
14
  return typeof item === 'object' && !item.type;
@@ -58,9 +58,8 @@ exports.collectSidebarLinks = collectSidebarLinks;
58
58
  // /!\ docId order matters for navigation!
59
59
  function collectSidebarDocIds(sidebar) {
60
60
  return flattenSidebarItems(sidebar).flatMap((item) => {
61
- var _a;
62
61
  if (item.type === 'category') {
63
- return ((_a = item.link) === null || _a === void 0 ? void 0 : _a.type) === 'doc' ? [item.link.id] : [];
62
+ return item.link?.type === 'doc' ? [item.link.id] : [];
64
63
  }
65
64
  if (item.type === 'doc') {
66
65
  return [item.id];
@@ -95,8 +94,7 @@ function createSidebarsUtils(sidebars) {
95
94
  // Reverse mapping
96
95
  const docIdToSidebarName = Object.fromEntries(Object.entries(sidebarNameToDocIds).flatMap(([sidebarName, docIds]) => docIds.map((docId) => [docId, sidebarName])));
97
96
  function getFirstDocIdOfFirstSidebar() {
98
- var _a;
99
- return (_a = Object.values(sidebarNameToDocIds)[0]) === null || _a === void 0 ? void 0 : _a[0];
97
+ return Object.values(sidebarNameToDocIds)[0]?.[0];
100
98
  }
101
99
  function getSidebarNameByDocId(docId) {
102
100
  return docIdToSidebarName[docId];
@@ -155,14 +153,12 @@ function createSidebarsUtils(sidebars) {
155
153
  * unique). More reliable than using object identity
156
154
  */
157
155
  function getCategoryGeneratedIndexNavigation(categoryGeneratedIndexPermalink) {
158
- var _a;
159
156
  function isCurrentCategoryGeneratedIndexItem(item) {
160
- var _a;
161
157
  return (item.type === 'category' &&
162
- ((_a = item.link) === null || _a === void 0 ? void 0 : _a.type) === 'generated-index' &&
158
+ item.link?.type === 'generated-index' &&
163
159
  item.link.permalink === categoryGeneratedIndexPermalink);
164
160
  }
165
- const sidebarName = (_a = Object.entries(sidebarNameToNavigationItems).find(([, navigationItems]) => navigationItems.find(isCurrentCategoryGeneratedIndexItem))) === null || _a === void 0 ? void 0 : _a[0];
161
+ const sidebarName = Object.entries(sidebarNameToNavigationItems).find(([, navigationItems]) => navigationItems.find(isCurrentCategoryGeneratedIndexItem))?.[0];
166
162
  if (!sidebarName) {
167
163
  return emptySidebarNavigation();
168
164
  }
@@ -184,24 +180,23 @@ Available document ids are:
184
180
  }
185
181
  }
186
182
  function getFirstLink(sidebar) {
187
- var _a, _b, _c;
188
183
  for (const item of sidebar) {
189
184
  if (item.type === 'doc') {
190
185
  return {
191
186
  type: 'doc',
192
187
  id: item.id,
193
- label: (_a = item.label) !== null && _a !== void 0 ? _a : item.id,
188
+ label: item.label ?? item.id,
194
189
  };
195
190
  }
196
191
  else if (item.type === 'category') {
197
- if (((_b = item.link) === null || _b === void 0 ? void 0 : _b.type) === 'doc') {
192
+ if (item.link?.type === 'doc') {
198
193
  return {
199
194
  type: 'doc',
200
195
  id: item.link.id,
201
196
  label: item.label,
202
197
  };
203
198
  }
204
- else if (((_c = item.link) === null || _c === void 0 ? void 0 : _c.type) === 'generated-index') {
199
+ else if (item.link?.type === 'generated-index') {
205
200
  return {
206
201
  type: 'generated-index',
207
202
  slug: item.link.slug,
@@ -229,9 +224,8 @@ Available document ids are:
229
224
  }
230
225
  exports.createSidebarsUtils = createSidebarsUtils;
231
226
  function toDocNavigationLink(doc) {
232
- var _a;
233
227
  const { title, permalink, frontMatter: { pagination_label: paginationLabel, sidebar_label: sidebarLabel, }, } = doc;
234
- return { title: (_a = paginationLabel !== null && paginationLabel !== void 0 ? paginationLabel : sidebarLabel) !== null && _a !== void 0 ? _a : title, permalink };
228
+ return { title: paginationLabel ?? sidebarLabel ?? title, permalink };
235
229
  }
236
230
  exports.toDocNavigationLink = toDocNavigationLink;
237
231
  function toNavigationLink(navigationItem, docsById) {
package/lib/slug.js CHANGED
@@ -20,7 +20,7 @@ function getSlug({ baseID, frontMatterSlug, source, sourceDirName, stripDirNumbe
20
20
  return resolveDirname;
21
21
  }
22
22
  function computeSlug() {
23
- if (frontMatterSlug === null || frontMatterSlug === void 0 ? void 0 : frontMatterSlug.startsWith('/')) {
23
+ if (frontMatterSlug?.startsWith('/')) {
24
24
  return frontMatterSlug;
25
25
  }
26
26
  const dirNameSlug = getDirNameSlug();
package/lib/tags.js CHANGED
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getVersionTags = void 0;
10
10
  const tslib_1 = require("tslib");
11
11
  const utils_1 = require("@docusaurus/utils");
12
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
12
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
13
13
  function getVersionTags(docs) {
14
14
  const groups = (0, utils_1.groupTaggedItems)(docs, (doc) => doc.tags);
15
15
  return lodash_1.default.mapValues(groups, (group) => ({
@@ -8,7 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.translateLoadedContent = exports.getLoadedContentTranslationFiles = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
11
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
12
12
  const utils_1 = require("./sidebars/utils");
13
13
  const utils_2 = require("@docusaurus/utils");
14
14
  const constants_1 = require("./constants");
@@ -120,13 +120,12 @@ function getSidebarTranslationFileContent(sidebar, sidebarName) {
120
120
  }
121
121
  function translateSidebar({ sidebar, sidebarName, sidebarsTranslations, }) {
122
122
  function transformSidebarCategoryLink(category) {
123
- var _a, _b, _c, _d;
124
123
  if (!category.link) {
125
124
  return undefined;
126
125
  }
127
126
  if (category.link.type === 'generated-index') {
128
- const title = (_b = (_a = sidebarsTranslations[`sidebar.${sidebarName}.category.${category.label}.link.generated-index.title`]) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : category.link.title;
129
- const description = (_d = (_c = sidebarsTranslations[`sidebar.${sidebarName}.category.${category.label}.link.generated-index.description`]) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : category.link.description;
127
+ const title = sidebarsTranslations[`sidebar.${sidebarName}.category.${category.label}.link.generated-index.title`]?.message ?? category.link.title;
128
+ const description = sidebarsTranslations[`sidebar.${sidebarName}.category.${category.label}.link.generated-index.description`]?.message ?? category.link.description;
130
129
  return {
131
130
  ...category.link,
132
131
  title,
@@ -136,19 +135,20 @@ function translateSidebar({ sidebar, sidebarName, sidebarsTranslations, }) {
136
135
  return category.link;
137
136
  }
138
137
  return (0, utils_1.transformSidebarItems)(sidebar, (item) => {
139
- var _a, _b, _c, _d;
140
138
  if (item.type === 'category') {
141
139
  const link = transformSidebarCategoryLink(item);
142
140
  return {
143
141
  ...item,
144
- label: (_b = (_a = sidebarsTranslations[`sidebar.${sidebarName}.category.${item.label}`]) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : item.label,
142
+ label: sidebarsTranslations[`sidebar.${sidebarName}.category.${item.label}`]
143
+ ?.message ?? item.label,
145
144
  ...(link && { link }),
146
145
  };
147
146
  }
148
147
  if (item.type === 'link') {
149
148
  return {
150
149
  ...item,
151
- label: (_d = (_c = sidebarsTranslations[`sidebar.${sidebarName}.link.${item.label}`]) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : item.label,
150
+ label: sidebarsTranslations[`sidebar.${sidebarName}.link.${item.label}`]
151
+ ?.message ?? item.label,
152
152
  };
153
153
  }
154
154
  return item;
@@ -195,11 +195,10 @@ function getVersionTranslationFiles(version) {
195
195
  ];
196
196
  }
197
197
  function translateVersion(version, translationFiles) {
198
- var _a;
199
198
  const versionTranslations = translationFiles[getVersionFileName(version.versionName)].content;
200
199
  return {
201
200
  ...version,
202
- versionLabel: (_a = versionTranslations['version.label']) === null || _a === void 0 ? void 0 : _a.message,
201
+ versionLabel: versionTranslations['version.label']?.message,
203
202
  sidebars: translateSidebars(version, versionTranslations),
204
203
  // docs: translateDocs(version.docs, versionTranslations),
205
204
  };
package/lib/versions.js CHANGED
@@ -8,11 +8,11 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getDocsDirPaths = exports.readVersionsMetadata = exports.filterVersions = exports.getVersionBadge = exports.getVersionBanner = exports.getDefaultVersionBanner = exports.readVersionNames = exports.readVersionsFile = exports.getVersionsFilePath = exports.getVersionedSidebarsDirPath = exports.getVersionedDocsDirPath = void 0;
10
10
  const tslib_1 = require("tslib");
11
- const path_1 = (0, tslib_1.__importDefault)(require("path"));
12
- const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
11
+ const path_1 = tslib_1.__importDefault(require("path"));
12
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
13
13
  const constants_1 = require("./constants");
14
14
  const utils_1 = require("@docusaurus/utils");
15
- const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
15
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
16
16
  const sidebars_1 = require("./sidebars");
17
17
  // retro-compatibility: no prefix for the default plugin id
18
18
  function addPluginIdPrefix(fileOrDir, pluginId) {
@@ -62,7 +62,7 @@ async function readVersionNames(siteDir, options) {
62
62
  if (!versionFileContent && options.disableVersioning) {
63
63
  throw new Error(`Docs: using "disableVersioning: ${options.disableVersioning}" option on a non-versioned site does not make sense.`);
64
64
  }
65
- const versions = options.disableVersioning ? [] : versionFileContent !== null && versionFileContent !== void 0 ? versionFileContent : [];
65
+ const versions = options.disableVersioning ? [] : versionFileContent ?? [];
66
66
  // We add the current version at the beginning, unless:
67
67
  // - user don't want to; or
68
68
  // - it's already been explicitly added to versions.json
@@ -154,8 +154,7 @@ function getDefaultVersionBanner({ versionName, versionNames, lastVersionName, }
154
154
  }
155
155
  exports.getDefaultVersionBanner = getDefaultVersionBanner;
156
156
  function getVersionBanner({ versionName, versionNames, lastVersionName, options, }) {
157
- var _a;
158
- const versionBannerOption = (_a = options.versions[versionName]) === null || _a === void 0 ? void 0 : _a.banner;
157
+ const versionBannerOption = options.versions[versionName]?.banner;
159
158
  if (versionBannerOption) {
160
159
  return versionBannerOption === 'none' ? null : versionBannerOption;
161
160
  }
@@ -167,23 +166,20 @@ function getVersionBanner({ versionName, versionNames, lastVersionName, options,
167
166
  }
168
167
  exports.getVersionBanner = getVersionBanner;
169
168
  function getVersionBadge({ versionName, versionNames, options, }) {
170
- var _a;
171
- const versionBadgeOption = (_a = options.versions[versionName]) === null || _a === void 0 ? void 0 : _a.badge;
169
+ const versionBadgeOption = options.versions[versionName]?.badge;
172
170
  // If site is not versioned or only one version is included
173
171
  // we don't show the version badge by default
174
172
  // See https://github.com/facebook/docusaurus/issues/3362
175
173
  const versionBadgeDefault = versionNames.length !== 1;
176
- return versionBadgeOption !== null && versionBadgeOption !== void 0 ? versionBadgeOption : versionBadgeDefault;
174
+ return versionBadgeOption ?? versionBadgeDefault;
177
175
  }
178
176
  exports.getVersionBadge = getVersionBadge;
179
177
  function getVersionClassName({ versionName, options, }) {
180
- var _a;
181
- const versionClassNameOption = (_a = options.versions[versionName]) === null || _a === void 0 ? void 0 : _a.className;
178
+ const versionClassNameOption = options.versions[versionName]?.className;
182
179
  const versionClassNameDefault = `docs-version-${versionName}`;
183
- return versionClassNameOption !== null && versionClassNameOption !== void 0 ? versionClassNameOption : versionClassNameDefault;
180
+ return versionClassNameOption ?? versionClassNameDefault;
184
181
  }
185
182
  function createVersionMetadata({ versionName, versionNames, lastVersionName, context, options, }) {
186
- var _a, _b, _c;
187
183
  const { sidebarFilePath, contentPath, contentPathLocalized } = getVersionMetadataPaths({ versionName, context, options });
188
184
  const isLast = versionName === lastVersionName;
189
185
  // retro-compatible values
@@ -195,9 +191,9 @@ function createVersionMetadata({ versionName, versionNames, lastVersionName, con
195
191
  return versionName === constants_1.CURRENT_VERSION_NAME ? 'next' : versionName;
196
192
  }
197
193
  const defaultVersionPathPart = getDefaultVersionPathPart();
198
- const versionOptions = (_a = options.versions[versionName]) !== null && _a !== void 0 ? _a : {};
199
- const versionLabel = (_b = versionOptions.label) !== null && _b !== void 0 ? _b : defaultVersionLabel;
200
- const versionPathPart = (_c = versionOptions.path) !== null && _c !== void 0 ? _c : defaultVersionPathPart;
194
+ const versionOptions = options.versions[versionName] ?? {};
195
+ const versionLabel = versionOptions.label ?? defaultVersionLabel;
196
+ const versionPathPart = versionOptions.path ?? defaultVersionPathPart;
201
197
  const versionPath = (0, utils_1.normalizeUrl)([
202
198
  context.baseUrl,
203
199
  options.routeBasePath,
@@ -219,8 +215,8 @@ function createVersionMetadata({ versionName, versionNames, lastVersionName, con
219
215
  versionLabel,
220
216
  versionPath,
221
217
  tagsPath,
222
- versionEditUrl: versionEditUrls === null || versionEditUrls === void 0 ? void 0 : versionEditUrls.versionEditUrl,
223
- versionEditUrlLocalized: versionEditUrls === null || versionEditUrls === void 0 ? void 0 : versionEditUrls.versionEditUrlLocalized,
218
+ versionEditUrl: versionEditUrls?.versionEditUrl,
219
+ versionEditUrlLocalized: versionEditUrls?.versionEditUrlLocalized,
224
220
  versionBanner: getVersionBanner({
225
221
  versionName,
226
222
  versionNames,
@@ -304,11 +300,10 @@ function filterVersions(versionNamesUnfiltered, options) {
304
300
  }
305
301
  exports.filterVersions = filterVersions;
306
302
  async function readVersionsMetadata({ context, options, }) {
307
- var _a;
308
303
  const versionNamesUnfiltered = await readVersionNames(context.siteDir, options);
309
304
  checkVersionsOptions(versionNamesUnfiltered, options);
310
305
  const versionNames = filterVersions(versionNamesUnfiltered, options);
311
- const lastVersionName = (_a = options.lastVersion) !== null && _a !== void 0 ? _a : getDefaultLastVersionName(versionNames);
306
+ const lastVersionName = options.lastVersion ?? getDefaultLastVersionName(versionNames);
312
307
  const versionsMetadata = versionNames.map((versionName) => createVersionMetadata({
313
308
  versionName,
314
309
  versionNames,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "0.0.0-4644",
3
+ "version": "0.0.0-4645",
4
4
  "description": "Docs plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -23,11 +23,11 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
- "@docusaurus/core": "0.0.0-4644",
27
- "@docusaurus/logger": "0.0.0-4644",
28
- "@docusaurus/mdx-loader": "0.0.0-4644",
29
- "@docusaurus/utils": "0.0.0-4644",
30
- "@docusaurus/utils-validation": "0.0.0-4644",
26
+ "@docusaurus/core": "0.0.0-4645",
27
+ "@docusaurus/logger": "0.0.0-4645",
28
+ "@docusaurus/mdx-loader": "0.0.0-4645",
29
+ "@docusaurus/utils": "0.0.0-4645",
30
+ "@docusaurus/utils-validation": "0.0.0-4645",
31
31
  "combine-promises": "^1.1.0",
32
32
  "fs-extra": "^10.0.1",
33
33
  "import-fresh": "^3.3.0",
@@ -39,8 +39,8 @@
39
39
  "webpack": "^5.69.1"
40
40
  },
41
41
  "devDependencies": {
42
- "@docusaurus/module-type-aliases": "0.0.0-4644",
43
- "@docusaurus/types": "0.0.0-4644",
42
+ "@docusaurus/module-type-aliases": "0.0.0-4645",
43
+ "@docusaurus/types": "0.0.0-4645",
44
44
  "@types/js-yaml": "^4.0.5",
45
45
  "@types/picomatch": "^2.3.0",
46
46
  "commander": "^5.1.0",
@@ -56,5 +56,5 @@
56
56
  "engines": {
57
57
  "node": ">=14"
58
58
  },
59
- "gitHead": "db54c31510baab4b2b18b25817cf64cf542e39fb"
59
+ "gitHead": "4eb744d0323996e14e1e1cc164fc925b0a9280fd"
60
60
  }