@docusaurus/plugin-content-docs 0.0.0-5023 → 0.0.0-5027

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.
@@ -1,22 +1,19 @@
1
- "use strict";
2
1
  /**
3
2
  * Copyright (c) Facebook, Inc. and its affiliates.
4
3
  *
5
4
  * This source code is licensed under the MIT license found in the
6
5
  * LICENSE file in the root directory of this source tree.
7
6
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getDocVersionSuggestions = exports.getActiveDocContext = exports.getActiveVersion = exports.getLatestVersion = exports.getActivePlugin = void 0;
10
- const router_1 = require("@docusaurus/router");
7
+ import { matchPath } from '@docusaurus/router';
11
8
  // This code is not part of the api surface, not in ./theme on purpose
12
9
  // get the data of the plugin that is currently "active"
13
10
  // ie the docs of that plugin are currently browsed
14
11
  // it is useful to support multiple docs plugin instances
15
- function getActivePlugin(allPluginData, pathname, options = {}) {
12
+ export function getActivePlugin(allPluginData, pathname, options = {}) {
16
13
  const activeEntry = Object.entries(allPluginData)
17
14
  // Route sorting: '/android/foo' should match '/android' instead of '/'
18
15
  .sort((a, b) => b[1].path.localeCompare(a[1].path))
19
- .find(([, pluginData]) => !!(0, router_1.matchPath)(pathname, {
16
+ .find(([, pluginData]) => !!matchPath(pathname, {
20
17
  path: pluginData.path,
21
18
  exact: false,
22
19
  strict: false,
@@ -31,27 +28,24 @@ function getActivePlugin(allPluginData, pathname, options = {}) {
31
28
  }
32
29
  return activePlugin;
33
30
  }
34
- exports.getActivePlugin = getActivePlugin;
35
- const getLatestVersion = (data) => data.versions.find((version) => version.isLast);
36
- exports.getLatestVersion = getLatestVersion;
37
- function getActiveVersion(data, pathname) {
38
- const lastVersion = (0, exports.getLatestVersion)(data);
31
+ export const getLatestVersion = (data) => data.versions.find((version) => version.isLast);
32
+ export function getActiveVersion(data, pathname) {
33
+ const lastVersion = getLatestVersion(data);
39
34
  // Last version is a route like /docs/*,
40
35
  // we need to match it last or it would match /docs/version-1.0/* as well
41
36
  const orderedVersionsMetadata = [
42
37
  ...data.versions.filter((version) => version !== lastVersion),
43
38
  lastVersion,
44
39
  ];
45
- return orderedVersionsMetadata.find((version) => !!(0, router_1.matchPath)(pathname, {
40
+ return orderedVersionsMetadata.find((version) => !!matchPath(pathname, {
46
41
  path: version.path,
47
42
  exact: false,
48
43
  strict: false,
49
44
  }));
50
45
  }
51
- exports.getActiveVersion = getActiveVersion;
52
- function getActiveDocContext(data, pathname) {
46
+ export function getActiveDocContext(data, pathname) {
53
47
  const activeVersion = getActiveVersion(data, pathname);
54
- const activeDoc = activeVersion?.docs.find((doc) => !!(0, router_1.matchPath)(pathname, {
48
+ const activeDoc = activeVersion?.docs.find((doc) => !!matchPath(pathname, {
55
49
  path: doc.path,
56
50
  exact: true,
57
51
  strict: false,
@@ -76,11 +70,9 @@ function getActiveDocContext(data, pathname) {
76
70
  alternateDocVersions: alternateVersionDocs,
77
71
  };
78
72
  }
79
- exports.getActiveDocContext = getActiveDocContext;
80
- function getDocVersionSuggestions(data, pathname) {
81
- const latestVersion = (0, exports.getLatestVersion)(data);
73
+ export function getDocVersionSuggestions(data, pathname) {
74
+ const latestVersion = getLatestVersion(data);
82
75
  const activeDocContext = getActiveDocContext(data, pathname);
83
76
  const latestDocSuggestion = activeDocContext?.alternateDocVersions[latestVersion.name];
84
77
  return { latestDocSuggestion, latestVersionSuggestion: latestVersion };
85
78
  }
86
- exports.getDocVersionSuggestions = getDocVersionSuggestions;
@@ -1,72 +1,60 @@
1
- "use strict";
2
1
  /**
3
2
  * Copyright (c) Facebook, Inc. and its affiliates.
4
3
  *
5
4
  * This source code is licensed under the MIT license found in the
6
5
  * LICENSE file in the root directory of this source tree.
7
6
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.useDocVersionSuggestions = exports.useActiveDocContext = exports.useActiveVersion = exports.useLatestVersion = exports.useVersions = exports.useActivePluginAndVersion = exports.useActivePlugin = exports.useDocsData = exports.useAllDocsData = void 0;
10
- const router_1 = require("@docusaurus/router");
11
- const useGlobalData_1 = require("@docusaurus/useGlobalData");
12
- const docsClientUtils_1 = require("./docsClientUtils");
7
+ import { useLocation } from '@docusaurus/router';
8
+ import { useAllPluginInstancesData, usePluginData, } from '@docusaurus/useGlobalData';
9
+ import { getActivePlugin, getLatestVersion, getActiveVersion, getActiveDocContext, getDocVersionSuggestions, } from './docsClientUtils';
13
10
  // Important to use a constant object to avoid React useEffect executions etc.
14
11
  // see https://github.com/facebook/docusaurus/issues/5089
15
12
  const StableEmptyObject = {};
16
13
  // In blog-only mode, docs hooks are still used by the theme. We need a fail-
17
14
  // safe fallback when the docs plugin is not in use
18
- const useAllDocsData = () => (0, useGlobalData_1.useAllPluginInstancesData)('docusaurus-plugin-content-docs') ??
15
+ export const useAllDocsData = () => useAllPluginInstancesData('docusaurus-plugin-content-docs') ??
19
16
  StableEmptyObject;
20
- exports.useAllDocsData = useAllDocsData;
21
- const useDocsData = (pluginId) => (0, useGlobalData_1.usePluginData)('docusaurus-plugin-content-docs', pluginId, {
17
+ export const useDocsData = (pluginId) => usePluginData('docusaurus-plugin-content-docs', pluginId, {
22
18
  failfast: true,
23
19
  });
24
- exports.useDocsData = useDocsData;
25
20
  // TODO this feature should be provided by docusaurus core
26
- function useActivePlugin(options = {}) {
27
- const data = (0, exports.useAllDocsData)();
28
- const { pathname } = (0, router_1.useLocation)();
29
- return (0, docsClientUtils_1.getActivePlugin)(data, pathname, options);
21
+ export function useActivePlugin(options = {}) {
22
+ const data = useAllDocsData();
23
+ const { pathname } = useLocation();
24
+ return getActivePlugin(data, pathname, options);
30
25
  }
31
- exports.useActivePlugin = useActivePlugin;
32
- function useActivePluginAndVersion(options = {}) {
26
+ export function useActivePluginAndVersion(options = {}) {
33
27
  const activePlugin = useActivePlugin(options);
34
- const { pathname } = (0, router_1.useLocation)();
28
+ const { pathname } = useLocation();
35
29
  if (!activePlugin) {
36
30
  return undefined;
37
31
  }
38
- const activeVersion = (0, docsClientUtils_1.getActiveVersion)(activePlugin.pluginData, pathname);
32
+ const activeVersion = getActiveVersion(activePlugin.pluginData, pathname);
39
33
  return {
40
34
  activePlugin,
41
35
  activeVersion,
42
36
  };
43
37
  }
44
- exports.useActivePluginAndVersion = useActivePluginAndVersion;
45
- function useVersions(pluginId) {
46
- const data = (0, exports.useDocsData)(pluginId);
38
+ export function useVersions(pluginId) {
39
+ const data = useDocsData(pluginId);
47
40
  return data.versions;
48
41
  }
49
- exports.useVersions = useVersions;
50
- function useLatestVersion(pluginId) {
51
- const data = (0, exports.useDocsData)(pluginId);
52
- return (0, docsClientUtils_1.getLatestVersion)(data);
42
+ export function useLatestVersion(pluginId) {
43
+ const data = useDocsData(pluginId);
44
+ return getLatestVersion(data);
53
45
  }
54
- exports.useLatestVersion = useLatestVersion;
55
- function useActiveVersion(pluginId) {
56
- const data = (0, exports.useDocsData)(pluginId);
57
- const { pathname } = (0, router_1.useLocation)();
58
- return (0, docsClientUtils_1.getActiveVersion)(data, pathname);
46
+ export function useActiveVersion(pluginId) {
47
+ const data = useDocsData(pluginId);
48
+ const { pathname } = useLocation();
49
+ return getActiveVersion(data, pathname);
59
50
  }
60
- exports.useActiveVersion = useActiveVersion;
61
- function useActiveDocContext(pluginId) {
62
- const data = (0, exports.useDocsData)(pluginId);
63
- const { pathname } = (0, router_1.useLocation)();
64
- return (0, docsClientUtils_1.getActiveDocContext)(data, pathname);
51
+ export function useActiveDocContext(pluginId) {
52
+ const data = useDocsData(pluginId);
53
+ const { pathname } = useLocation();
54
+ return getActiveDocContext(data, pathname);
65
55
  }
66
- exports.useActiveDocContext = useActiveDocContext;
67
- function useDocVersionSuggestions(pluginId) {
68
- const data = (0, exports.useDocsData)(pluginId);
69
- const { pathname } = (0, router_1.useLocation)();
70
- return (0, docsClientUtils_1.getDocVersionSuggestions)(data, pathname);
56
+ export function useDocVersionSuggestions(pluginId) {
57
+ const data = useDocsData(pluginId);
58
+ const { pathname } = useLocation();
59
+ return getDocVersionSuggestions(data, pathname);
71
60
  }
72
- exports.useDocVersionSuggestions = useDocVersionSuggestions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "0.0.0-5023",
3
+ "version": "0.0.0-5027",
4
4
  "description": "Docs plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "sideEffects": false,
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "types": "src/plugin-content-docs.d.ts",
14
14
  "scripts": {
15
- "build": "tsc",
15
+ "build": "tsc --build",
16
16
  "watch": "tsc --watch"
17
17
  },
18
18
  "publishConfig": {
@@ -25,11 +25,11 @@
25
25
  },
26
26
  "license": "MIT",
27
27
  "dependencies": {
28
- "@docusaurus/core": "0.0.0-5023",
29
- "@docusaurus/logger": "0.0.0-5023",
30
- "@docusaurus/mdx-loader": "0.0.0-5023",
31
- "@docusaurus/utils": "0.0.0-5023",
32
- "@docusaurus/utils-validation": "0.0.0-5023",
28
+ "@docusaurus/core": "0.0.0-5027",
29
+ "@docusaurus/logger": "0.0.0-5027",
30
+ "@docusaurus/mdx-loader": "0.0.0-5027",
31
+ "@docusaurus/utils": "0.0.0-5027",
32
+ "@docusaurus/utils-validation": "0.0.0-5027",
33
33
  "combine-promises": "^1.1.0",
34
34
  "fs-extra": "^10.1.0",
35
35
  "import-fresh": "^3.3.0",
@@ -41,8 +41,8 @@
41
41
  "webpack": "^5.72.1"
42
42
  },
43
43
  "devDependencies": {
44
- "@docusaurus/module-type-aliases": "0.0.0-5023",
45
- "@docusaurus/types": "0.0.0-5023",
44
+ "@docusaurus/module-type-aliases": "0.0.0-5027",
45
+ "@docusaurus/types": "0.0.0-5027",
46
46
  "@types/js-yaml": "^4.0.5",
47
47
  "@types/picomatch": "^2.3.0",
48
48
  "commander": "^5.1.0",
@@ -58,5 +58,5 @@
58
58
  "engines": {
59
59
  "node": ">=14"
60
60
  },
61
- "gitHead": "e982ebda1c6b2210cce9d2b972f441f3ef3201ac"
61
+ "gitHead": "780d7af951f49f7c5ac0cb04626844935d0ada7b"
62
62
  }
@@ -5,6 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
+ /// <reference types="@docusaurus/module-type-aliases" />
9
+
8
10
  declare module '@docusaurus/plugin-content-docs' {
9
11
  import type {MDXOptions} from '@docusaurus/mdx-loader';
10
12
  import type {
package/src/types.ts CHANGED
@@ -5,8 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- /// <reference types="@docusaurus/module-type-aliases" />
9
-
10
8
  import type {BrokenMarkdownLink, Tag} from '@docusaurus/utils';
11
9
  import type {
12
10
  VersionMetadata,