@docusaurus/plugin-content-docs 0.0.0-4203 → 0.0.0-4207

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/lib/.tsbuildinfo +1 -1
  2. package/lib/client/docsClientUtils.js +11 -17
  3. package/lib/docFrontMatter.d.ts +1 -1
  4. package/lib/docs.d.ts +1 -1
  5. package/lib/globalData.d.ts +1 -1
  6. package/lib/index.d.ts +1 -1
  7. package/lib/numberPrefix.d.ts +1 -1
  8. package/lib/options.d.ts +2 -2
  9. package/lib/props.d.ts +1 -1
  10. package/lib/sidebars/normalization.d.ts +1 -1
  11. package/lib/sidebars/normalization.js +2 -2
  12. package/lib/sidebars/types.d.ts +1 -2
  13. package/lib/sidebars/types.js +0 -5
  14. package/lib/sidebars/utils.d.ts +2 -1
  15. package/lib/sidebars/utils.js +6 -4
  16. package/lib/sidebars/validation.d.ts +1 -1
  17. package/lib/sidebars/validation.js +2 -2
  18. package/lib/slug.d.ts +1 -1
  19. package/lib/tags.d.ts +1 -1
  20. package/lib/tags.js +5 -7
  21. package/lib/translations.d.ts +1 -1
  22. package/lib/translations.js +8 -10
  23. package/lib/versions.d.ts +2 -2
  24. package/package.json +8 -8
  25. package/src/__tests__/docs.test.ts +2 -2
  26. package/src/__tests__/index.test.ts +1 -1
  27. package/src/__tests__/versions.test.ts +4 -6
  28. package/src/client/docsClientUtils.ts +13 -14
  29. package/src/docFrontMatter.ts +1 -1
  30. package/src/docs.ts +1 -1
  31. package/src/globalData.ts +6 -1
  32. package/src/index.ts +2 -2
  33. package/src/numberPrefix.ts +1 -1
  34. package/src/options.ts +5 -2
  35. package/src/plugin-content-docs.d.ts +0 -2
  36. package/src/props.ts +1 -1
  37. package/src/sidebars/__tests__/generator.test.ts +8 -6
  38. package/src/sidebars/__tests__/processor.test.ts +1 -3
  39. package/src/sidebars/normalization.ts +2 -2
  40. package/src/sidebars/types.ts +1 -7
  41. package/src/sidebars/utils.ts +11 -3
  42. package/src/sidebars/validation.ts +2 -2
  43. package/src/slug.ts +1 -1
  44. package/src/tags.ts +6 -8
  45. package/src/translations.ts +5 -5
  46. package/src/types.ts +0 -2
  47. package/src/versions.ts +2 -2
@@ -6,9 +6,13 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.createSidebarsUtils = exports.collectSidebarsDocIds = exports.collectSidebarLinks = exports.collectSidebarCategories = exports.collectSidebarDocItems = exports.transformSidebarItems = void 0;
9
+ exports.createSidebarsUtils = exports.collectSidebarsDocIds = exports.collectSidebarLinks = exports.collectSidebarCategories = exports.collectSidebarDocItems = exports.transformSidebarItems = exports.isCategoriesShorthand = void 0;
10
10
  const lodash_1 = require("lodash");
11
11
  const utils_1 = require("@docusaurus/utils");
12
+ function isCategoriesShorthand(item) {
13
+ return typeof item !== 'string' && !item.type;
14
+ }
15
+ exports.isCategoriesShorthand = isCategoriesShorthand;
12
16
  function transformSidebarItems(sidebar, updateFn) {
13
17
  function transformRecursive(item) {
14
18
  if (item.type === 'category') {
@@ -43,9 +47,7 @@ function collectSidebarLinks(sidebar) {
43
47
  }
44
48
  exports.collectSidebarLinks = collectSidebarLinks;
45
49
  function collectSidebarsDocIds(sidebars) {
46
- return (0, lodash_1.mapValues)(sidebars, (sidebar) => {
47
- return collectSidebarDocItems(sidebar).map((docItem) => docItem.id);
48
- });
50
+ return (0, lodash_1.mapValues)(sidebars, (sidebar) => collectSidebarDocItems(sidebar).map((docItem) => docItem.id));
49
51
  }
50
52
  exports.collectSidebarsDocIds = collectSidebarsDocIds;
51
53
  function createSidebarsUtils(sidebars) {
@@ -4,5 +4,5 @@
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
- import { SidebarsConfig } from './types';
7
+ import type { SidebarsConfig } from './types';
8
8
  export declare function validateSidebars(sidebars: unknown): asserts sidebars is SidebarsConfig;
@@ -8,7 +8,7 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.validateSidebars = void 0;
10
10
  const utils_validation_1 = require("@docusaurus/utils-validation");
11
- const types_1 = require("./types");
11
+ const utils_1 = require("./utils");
12
12
  const sidebarItemBaseSchema = utils_validation_1.Joi.object({
13
13
  className: utils_validation_1.Joi.string(),
14
14
  customProps: utils_validation_1.Joi.object().unknown(),
@@ -79,7 +79,7 @@ function validateSidebarItem(item) {
79
79
  }
80
80
  // TODO: remove once with proper Joi support
81
81
  // Because we can't use Joi to validate nested items (see above), we do it manually
82
- if ((0, types_1.isCategoriesShorthand)(item)) {
82
+ if ((0, utils_1.isCategoriesShorthand)(item)) {
83
83
  Object.values(item).forEach((category) => category.forEach(validateSidebarItem));
84
84
  }
85
85
  else {
package/lib/slug.d.ts CHANGED
@@ -4,7 +4,7 @@
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
- import { NumberPrefixParser } from './types';
7
+ import type { NumberPrefixParser } from './types';
8
8
  export default function getSlug({ baseID, frontmatterSlug, dirName, stripDirNumberPrefixes, numberPrefixParser, }: {
9
9
  baseID: string;
10
10
  frontmatterSlug?: string;
package/lib/tags.d.ts CHANGED
@@ -4,5 +4,5 @@
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
- import { VersionTags, DocMetadata } from './types';
7
+ import type { VersionTags, DocMetadata } from './types';
8
8
  export declare function getVersionTags(docs: DocMetadata[]): VersionTags;
package/lib/tags.js CHANGED
@@ -11,12 +11,10 @@ const utils_1 = require("@docusaurus/utils");
11
11
  const lodash_1 = require("lodash");
12
12
  function getVersionTags(docs) {
13
13
  const groups = (0, utils_1.groupTaggedItems)(docs, (doc) => doc.tags);
14
- return (0, lodash_1.mapValues)(groups, (group) => {
15
- return {
16
- name: group.tag.label,
17
- docIds: group.items.map((item) => item.id),
18
- permalink: group.tag.permalink,
19
- };
20
- });
14
+ return (0, lodash_1.mapValues)(groups, (group) => ({
15
+ name: group.tag.label,
16
+ docIds: group.items.map((item) => item.id),
17
+ permalink: group.tag.permalink,
18
+ }));
21
19
  }
22
20
  exports.getVersionTags = getVersionTags;
@@ -5,6 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { LoadedContent } from './types';
8
- import { TranslationFile, TranslationFiles } from '@docusaurus/types';
8
+ import type { TranslationFile, TranslationFiles } from '@docusaurus/types';
9
9
  export declare function getLoadedContentTranslationFiles(loadedContent: LoadedContent): TranslationFiles;
10
10
  export declare function translateLoadedContent(loadedContent: LoadedContent, translationFiles: TranslationFile[]): LoadedContent;
@@ -120,16 +120,14 @@ function getSidebarsTranslations(version) {
120
120
  }));
121
121
  }
122
122
  function translateSidebars(version, sidebarsTranslations) {
123
- return (0, lodash_1.mapValues)(version.sidebars, (sidebar, sidebarName) => {
124
- return translateSidebar({
125
- sidebar,
126
- sidebarName: getNormalizedSidebarName({
127
- sidebarName,
128
- versionName: version.versionName,
129
- }),
130
- sidebarsTranslations,
131
- });
132
- });
123
+ return (0, lodash_1.mapValues)(version.sidebars, (sidebar, sidebarName) => translateSidebar({
124
+ sidebar,
125
+ sidebarName: getNormalizedSidebarName({
126
+ sidebarName,
127
+ versionName: version.versionName,
128
+ }),
129
+ sidebarsTranslations,
130
+ }));
133
131
  }
134
132
  function getVersionTranslationFiles(version) {
135
133
  const versionTranslations = {
package/lib/versions.d.ts CHANGED
@@ -4,8 +4,8 @@
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
- import { PluginOptions, VersionMetadata } from './types';
8
- import { LoadContext } from '@docusaurus/types';
7
+ import type { PluginOptions, VersionMetadata } from './types';
8
+ import type { LoadContext } from '@docusaurus/types';
9
9
  export declare function getVersionedDocsDirPath(siteDir: string, pluginId: string): string;
10
10
  export declare function getVersionedSidebarsDirPath(siteDir: string, pluginId: string): string;
11
11
  export declare function getVersionsFilePath(siteDir: string, pluginId: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "0.0.0-4203",
3
+ "version": "0.0.0-4207",
4
4
  "description": "Docs plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/plugin-content-docs.d.ts",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "devDependencies": {
21
- "@docusaurus/module-type-aliases": "0.0.0-4203",
21
+ "@docusaurus/module-type-aliases": "0.0.0-4207",
22
22
  "@types/js-yaml": "^4.0.0",
23
23
  "@types/picomatch": "^2.2.1",
24
24
  "commander": "^5.1.0",
@@ -26,11 +26,11 @@
26
26
  "utility-types": "^3.10.0"
27
27
  },
28
28
  "dependencies": {
29
- "@docusaurus/core": "0.0.0-4203",
30
- "@docusaurus/mdx-loader": "0.0.0-4203",
31
- "@docusaurus/types": "0.0.0-4203",
32
- "@docusaurus/utils": "0.0.0-4203",
33
- "@docusaurus/utils-validation": "0.0.0-4203",
29
+ "@docusaurus/core": "0.0.0-4207",
30
+ "@docusaurus/mdx-loader": "0.0.0-4207",
31
+ "@docusaurus/types": "0.0.0-4207",
32
+ "@docusaurus/utils": "0.0.0-4207",
33
+ "@docusaurus/utils-validation": "0.0.0-4207",
34
34
  "chalk": "^4.1.2",
35
35
  "combine-promises": "^1.1.0",
36
36
  "escape-string-regexp": "^4.0.0",
@@ -53,5 +53,5 @@
53
53
  "engines": {
54
54
  "node": ">=14"
55
55
  },
56
- "gitHead": "c593f92915e118d87c10015d5db2c42eda4b5ef3"
56
+ "gitHead": "63059ec789f63c76514839ed417d2ef58456666e"
57
57
  }
@@ -15,7 +15,7 @@ import {
15
15
  } from '../docs';
16
16
  import {loadSidebars} from '../sidebars';
17
17
  import {readVersionsMetadata} from '../versions';
18
- import {
18
+ import type {
19
19
  DocFile,
20
20
  DocMetadataBase,
21
21
  MetadataOptions,
@@ -24,7 +24,7 @@ import {
24
24
  EditUrlFunction,
25
25
  DocNavLink,
26
26
  } from '../types';
27
- import {LoadContext} from '@docusaurus/types';
27
+ import type {LoadContext} from '@docusaurus/types';
28
28
  import {DEFAULT_PLUGIN_ID} from '@docusaurus/core/lib/constants';
29
29
  import {DEFAULT_OPTIONS} from '../options';
30
30
  import {Optional} from 'utility-types';
@@ -14,7 +14,7 @@ import fs from 'fs-extra';
14
14
  import pluginContentDocs from '../index';
15
15
  import {loadContext} from '@docusaurus/core/src/server/index';
16
16
  import {applyConfigureWebpack} from '@docusaurus/core/src/webpack/utils';
17
- import {RouteConfig} from '@docusaurus/types';
17
+ import type {RouteConfig} from '@docusaurus/types';
18
18
  import {posixPath} from '@docusaurus/utils';
19
19
  import {sortConfig} from '@docusaurus/core/src/server/plugins';
20
20
  import {DEFAULT_PLUGIN_ID} from '@docusaurus/core/lib/constants';
@@ -15,7 +15,7 @@ import {
15
15
  import {DEFAULT_OPTIONS} from '../options';
16
16
  import {DEFAULT_PLUGIN_ID} from '@docusaurus/core/lib/constants';
17
17
  import {PluginOptions, VersionMetadata} from '../types';
18
- import {I18n} from '@docusaurus/types';
18
+ import type {I18n} from '@docusaurus/types';
19
19
 
20
20
  const DefaultI18N: I18n = {
21
21
  currentLocale: 'en',
@@ -600,11 +600,9 @@ describe('versioned site, pluginId=default', () => {
600
600
  test('readVersionsMetadata versioned site with invalid versions.json file', async () => {
601
601
  const {defaultOptions, defaultContext} = await loadSite();
602
602
 
603
- const mock = jest.spyOn(JSON, 'parse').mockImplementationOnce(() => {
604
- return {
605
- invalid: 'json',
606
- };
607
- });
603
+ const mock = jest.spyOn(JSON, 'parse').mockImplementationOnce(() => ({
604
+ invalid: 'json',
605
+ }));
608
606
 
609
607
  expect(() => {
610
608
  readVersionsMetadata({
@@ -31,13 +31,12 @@ export function getActivePlugin(
31
31
  options: GetActivePluginOptions = {},
32
32
  ): ActivePlugin | undefined {
33
33
  const activeEntry = Object.entries(allPluginDatas).find(
34
- ([_id, pluginData]) => {
35
- return !!matchPath(pathname, {
34
+ ([_id, pluginData]) =>
35
+ !!matchPath(pathname, {
36
36
  path: pluginData.path,
37
37
  exact: false,
38
38
  strict: false,
39
- });
40
- },
39
+ }),
41
40
  );
42
41
 
43
42
  const activePlugin: ActivePlugin | undefined = activeEntry
@@ -63,9 +62,8 @@ export type ActiveDocContext = {
63
62
  alternateDocVersions: Record<string, Doc>;
64
63
  };
65
64
 
66
- export const getLatestVersion = (data: GlobalPluginData): Version => {
67
- return data.versions.find((version) => version.isLast)!;
68
- };
65
+ export const getLatestVersion = (data: GlobalPluginData): Version =>
66
+ data.versions.find((version) => version.isLast)!;
69
67
 
70
68
  // Note: return undefined on doc-unrelated pages,
71
69
  // because there's no version currently considered as active
@@ -80,13 +78,14 @@ export const getActiveVersion = (
80
78
  ...data.versions.filter((version) => version !== lastVersion),
81
79
  lastVersion,
82
80
  ];
83
- return orderedVersionsMetadata.find((version) => {
84
- return !!matchPath(pathname, {
85
- path: version.path,
86
- exact: false,
87
- strict: false,
88
- });
89
- });
81
+ return orderedVersionsMetadata.find(
82
+ (version) =>
83
+ !!matchPath(pathname, {
84
+ path: version.path,
85
+ exact: false,
86
+ strict: false,
87
+ }),
88
+ );
90
89
  };
91
90
 
92
91
  export const getActiveDocContext = (
@@ -12,7 +12,7 @@ import {
12
12
  FrontMatterTOCHeadingLevels,
13
13
  validateFrontMatter,
14
14
  } from '@docusaurus/utils-validation';
15
- import {DocFrontMatter} from './types';
15
+ import type {DocFrontMatter} from './types';
16
16
 
17
17
  // NOTE: we don't add any default value on purpose here
18
18
  // We don't want default values to magically appear in doc metadata and props
package/src/docs.ts CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  Globby,
20
20
  normalizeFrontMatterTags,
21
21
  } from '@docusaurus/utils';
22
- import {LoadContext} from '@docusaurus/types';
22
+ import type {LoadContext} from '@docusaurus/types';
23
23
 
24
24
  import {getFileLastUpdate} from './lastUpdate';
25
25
  import {
package/src/globalData.ts CHANGED
@@ -5,7 +5,12 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import {DocMetadata, GlobalDoc, LoadedVersion, GlobalVersion} from './types';
8
+ import type {
9
+ DocMetadata,
10
+ GlobalDoc,
11
+ LoadedVersion,
12
+ GlobalVersion,
13
+ } from './types';
9
14
 
10
15
  export function toGlobalDataDoc(doc: DocMetadata): GlobalDoc {
11
16
  return {
package/src/index.ts CHANGED
@@ -20,7 +20,7 @@ import {
20
20
  addTrailingPathSeparator,
21
21
  createAbsoluteFilePathMatcher,
22
22
  } from '@docusaurus/utils';
23
- import {LoadContext, Plugin, RouteConfig} from '@docusaurus/types';
23
+ import type {LoadContext, Plugin, RouteConfig} from '@docusaurus/types';
24
24
  import {loadSidebars} from './sidebars';
25
25
  import {CategoryMetadataFilenamePattern} from './sidebars/generator';
26
26
  import {readVersionDocs, processDocMetadata, handleNavigation} from './docs';
@@ -39,7 +39,7 @@ import {
39
39
  DocsMarkdownOption,
40
40
  VersionTag,
41
41
  } from './types';
42
- import {RuleSetRule} from 'webpack';
42
+ import type {RuleSetRule} from 'webpack';
43
43
  import {cliDocsVersionCommand} from './cli';
44
44
  import {VERSIONS_JSON_FILE} from './constants';
45
45
  import {keyBy, mapValues} from 'lodash';
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import {NumberPrefixParser} from './types';
8
+ import type {NumberPrefixParser} from './types';
9
9
 
10
10
  // Best-effort to avoid parsing some patterns as number prefix
11
11
  const IgnoredPrefixPatterns = (function () {
package/src/options.ts CHANGED
@@ -4,7 +4,7 @@
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
- import {PluginOptions} from './types';
7
+ import type {PluginOptions} from './types';
8
8
  import {
9
9
  Joi,
10
10
  RemarkPluginsSchema,
@@ -14,7 +14,10 @@ import {
14
14
  } from '@docusaurus/utils-validation';
15
15
  import {GlobExcludeDefault} from '@docusaurus/utils';
16
16
 
17
- import {OptionValidationContext, ValidationResult} from '@docusaurus/types';
17
+ import type {
18
+ OptionValidationContext,
19
+ ValidationResult,
20
+ } from '@docusaurus/types';
18
21
  import chalk from 'chalk';
19
22
  import admonitions from 'remark-admonitions';
20
23
  import {DefaultSidebarItemsGenerator} from './sidebars/generator';
@@ -70,12 +70,10 @@ declare module '@theme/DocItem' {
70
70
  readonly title: string;
71
71
  readonly image?: string;
72
72
  readonly keywords?: readonly string[];
73
- /* eslint-disable camelcase */
74
73
  readonly hide_title?: boolean;
75
74
  readonly hide_table_of_contents?: boolean;
76
75
  readonly toc_min_heading_level?: number;
77
76
  readonly toc_max_heading_level?: number;
78
- /* eslint-enable camelcase */
79
77
  };
80
78
 
81
79
  export type Metadata = {
package/src/props.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import {LoadedVersion, VersionTag, DocMetadata} from './types';
8
+ import type {LoadedVersion, VersionTag, DocMetadata} from './types';
9
9
  import type {
10
10
  SidebarItemDoc,
11
11
  SidebarItemLink,
@@ -36,14 +36,16 @@ describe('DefaultSidebarItemsGenerator', () => {
36
36
  function mockCategoryMetadataFiles(
37
37
  categoryMetadataFiles: Record<string, Partial<CategoryMetadataFile>>,
38
38
  ) {
39
- jest.spyOn(fs, 'pathExists').mockImplementation((metadataFilePath) => {
40
- return typeof categoryMetadataFiles[metadataFilePath] !== 'undefined';
41
- });
39
+ jest
40
+ .spyOn(fs, 'pathExists')
41
+ .mockImplementation(
42
+ (metadataFilePath) =>
43
+ typeof categoryMetadataFiles[metadataFilePath] !== 'undefined',
44
+ );
42
45
  jest.spyOn(fs, 'readFile').mockImplementation(
43
46
  // @ts-expect-error: annoying TS error due to overrides
44
- async (metadataFilePath: string) => {
45
- return JSON.stringify(categoryMetadataFiles[metadataFilePath]);
46
- },
47
+ async (metadataFilePath: string) =>
48
+ JSON.stringify(categoryMetadataFiles[metadataFilePath]),
47
49
  );
48
50
  }
49
51
 
@@ -21,9 +21,7 @@ describe('processSidebars', () => {
21
21
  ];
22
22
 
23
23
  const StaticSidebarItemsGenerator: SidebarItemsGenerator = jest.fn(
24
- async () => {
25
- return StaticGeneratedSidebarSlice;
26
- },
24
+ async () => StaticGeneratedSidebarSlice,
27
25
  );
28
26
 
29
27
  async function testProcessSidebars(unprocessedSidebars: NormalizedSidebars) {
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import type {SidebarOptions} from '../types';
9
- import {
9
+ import type {
10
10
  NormalizedSidebarItem,
11
11
  NormalizedSidebar,
12
12
  NormalizedSidebars,
@@ -15,9 +15,9 @@ import {
15
15
  SidebarItemConfig,
16
16
  SidebarConfig,
17
17
  SidebarsConfig,
18
- isCategoriesShorthand,
19
18
  } from './types';
20
19
  import {mapValues} from 'lodash';
20
+ import {isCategoriesShorthand} from './utils';
21
21
 
22
22
  function normalizeCategoriesShorthand(
23
23
  sidebar: SidebarCategoriesShorthand,
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import {Optional} from 'utility-types';
8
+ import type {Optional} from 'utility-types';
9
9
  import type {
10
10
  DocMetadataBase,
11
11
  VersionMetadata,
@@ -56,12 +56,6 @@ export type SidebarCategoriesShorthand = {
56
56
  [sidebarCategory: string]: SidebarItemConfig[];
57
57
  };
58
58
 
59
- export function isCategoriesShorthand(
60
- item: SidebarItemConfig,
61
- ): item is SidebarCategoriesShorthand {
62
- return typeof item !== 'string' && !item.type;
63
- }
64
-
65
59
  export type SidebarItemConfig =
66
60
  | SidebarItemDoc
67
61
  | SidebarItemLink
@@ -13,10 +13,18 @@ import type {
13
13
  SidebarItemLink,
14
14
  SidebarItemDoc,
15
15
  SidebarItemType,
16
+ SidebarCategoriesShorthand,
17
+ SidebarItemConfig,
16
18
  } from './types';
17
19
  import {mapValues, difference} from 'lodash';
18
20
  import {getElementsAround, toMessageRelativeFilePath} from '@docusaurus/utils';
19
21
 
22
+ export function isCategoriesShorthand(
23
+ item: SidebarItemConfig,
24
+ ): item is SidebarCategoriesShorthand {
25
+ return typeof item !== 'string' && !item.type;
26
+ }
27
+
20
28
  export function transformSidebarItems(
21
29
  sidebar: Sidebar,
22
30
  updateFn: (item: SidebarItem) => SidebarItem,
@@ -65,9 +73,9 @@ export function collectSidebarLinks(sidebar: Sidebar): SidebarItemLink[] {
65
73
  export function collectSidebarsDocIds(
66
74
  sidebars: Sidebars,
67
75
  ): Record<string, string[]> {
68
- return mapValues(sidebars, (sidebar) => {
69
- return collectSidebarDocItems(sidebar).map((docItem) => docItem.id);
70
- });
76
+ return mapValues(sidebars, (sidebar) =>
77
+ collectSidebarDocItems(sidebar).map((docItem) => docItem.id),
78
+ );
71
79
  }
72
80
 
73
81
  export function createSidebarsUtils(sidebars: Sidebars): {
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import {Joi, URISchema} from '@docusaurus/utils-validation';
9
- import {
9
+ import type {
10
10
  SidebarItemConfig,
11
11
  SidebarCategoriesShorthand,
12
12
  SidebarItemBase,
@@ -15,8 +15,8 @@ import {
15
15
  SidebarItemLink,
16
16
  SidebarItemCategoryConfig,
17
17
  SidebarsConfig,
18
- isCategoriesShorthand,
19
18
  } from './types';
19
+ import {isCategoriesShorthand} from './utils';
20
20
 
21
21
  const sidebarItemBaseSchema = Joi.object<SidebarItemBase>({
22
22
  className: Joi.string(),
package/src/slug.ts CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  DefaultNumberPrefixParser,
16
16
  stripPathNumberPrefixes,
17
17
  } from './numberPrefix';
18
- import {NumberPrefixParser} from './types';
18
+ import type {NumberPrefixParser} from './types';
19
19
 
20
20
  export default function getSlug({
21
21
  baseID,
package/src/tags.ts CHANGED
@@ -6,16 +6,14 @@
6
6
  */
7
7
 
8
8
  import {groupTaggedItems} from '@docusaurus/utils';
9
- import {VersionTags, DocMetadata} from './types';
9
+ import type {VersionTags, DocMetadata} from './types';
10
10
  import {mapValues} from 'lodash';
11
11
 
12
12
  export function getVersionTags(docs: DocMetadata[]): VersionTags {
13
13
  const groups = groupTaggedItems(docs, (doc) => doc.tags);
14
- return mapValues(groups, (group) => {
15
- return {
16
- name: group.tag.label,
17
- docIds: group.items.map((item) => item.id),
18
- permalink: group.tag.permalink,
19
- };
20
- });
14
+ return mapValues(groups, (group) => ({
15
+ name: group.tag.label,
16
+ docIds: group.items.map((item) => item.id),
17
+ permalink: group.tag.permalink,
18
+ }));
21
19
  }
@@ -14,7 +14,7 @@ import {
14
14
  transformSidebarItems,
15
15
  collectSidebarLinks,
16
16
  } from './sidebars/utils';
17
- import {
17
+ import type {
18
18
  TranslationFileContent,
19
19
  TranslationFile,
20
20
  TranslationFiles,
@@ -164,16 +164,16 @@ function translateSidebars(
164
164
  version: LoadedVersion,
165
165
  sidebarsTranslations: TranslationFileContent,
166
166
  ): Sidebars {
167
- return mapValues(version.sidebars, (sidebar, sidebarName) => {
168
- return translateSidebar({
167
+ return mapValues(version.sidebars, (sidebar, sidebarName) =>
168
+ translateSidebar({
169
169
  sidebar,
170
170
  sidebarName: getNormalizedSidebarName({
171
171
  sidebarName,
172
172
  versionName: version.versionName,
173
173
  }),
174
174
  sidebarsTranslations,
175
- });
176
- });
175
+ }),
176
+ );
177
177
  }
178
178
 
179
179
  function getVersionTranslationFiles(version: LoadedVersion): TranslationFiles {
package/src/types.ts CHANGED
@@ -113,7 +113,6 @@ export type LastUpdateData = {
113
113
 
114
114
  export type DocFrontMatter = {
115
115
  // Front matter uses snake case
116
- /* eslint-disable camelcase */
117
116
  id?: string;
118
117
  title?: string;
119
118
  tags?: FrontMatterTag[];
@@ -133,7 +132,6 @@ export type DocFrontMatter = {
133
132
  toc_max_heading_level?: number;
134
133
  pagination_next?: string | null;
135
134
  pagination_prev?: string | null;
136
- /* eslint-enable camelcase */
137
135
  };
138
136
 
139
137
  export type DocMetadataBase = LastUpdateData & {
package/src/versions.ts CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  import path from 'path';
9
9
  import fs from 'fs-extra';
10
- import {
10
+ import type {
11
11
  PluginOptions,
12
12
  VersionBanner,
13
13
  VersionMetadata,
@@ -22,7 +22,7 @@ import {
22
22
  } from './constants';
23
23
 
24
24
  import {DEFAULT_PLUGIN_ID} from '@docusaurus/core/lib/constants';
25
- import {LoadContext} from '@docusaurus/types';
25
+ import type {LoadContext} from '@docusaurus/types';
26
26
  import {getPluginI18nPath, normalizeUrl, posixPath} from '@docusaurus/utils';
27
27
  import {difference} from 'lodash';
28
28
  import {resolveSidebarPathOption} from './sidebars';