@docusaurus/plugin-content-docs 0.0.0-4841 → 0.0.0-4844

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.
@@ -4,10 +4,11 @@
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 type { GlobalPluginData, GlobalVersion, GetActivePluginOptions, ActivePlugin, ActiveDocContext, DocVersionSuggestions } from '@docusaurus/plugin-content-docs/client';
7
+ import type { GlobalPluginData, GlobalVersion, ActivePlugin, ActiveDocContext, DocVersionSuggestions } from '@docusaurus/plugin-content-docs/client';
8
+ import type { UseDataOptions } from '@docusaurus/types';
8
9
  export declare function getActivePlugin(allPluginData: {
9
10
  [pluginId: string]: GlobalPluginData;
10
- }, pathname: string, options?: GetActivePluginOptions): ActivePlugin | undefined;
11
+ }, pathname: string, options?: UseDataOptions): ActivePlugin | undefined;
11
12
  export declare const getLatestVersion: (data: GlobalPluginData) => GlobalVersion;
12
13
  export declare const getActiveVersion: (data: GlobalPluginData, pathname: string) => GlobalVersion | undefined;
13
14
  export declare const getActiveDocContext: (data: GlobalPluginData, pathname: string) => ActiveDocContext;
@@ -4,13 +4,14 @@
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 type { GlobalPluginData, GlobalVersion, ActivePlugin, ActiveDocContext, DocVersionSuggestions, GetActivePluginOptions } from '@docusaurus/plugin-content-docs/client';
7
+ import type { GlobalPluginData, GlobalVersion, ActivePlugin, ActiveDocContext, DocVersionSuggestions } from '@docusaurus/plugin-content-docs/client';
8
+ import type { UseDataOptions } from '@docusaurus/types';
8
9
  export declare const useAllDocsData: () => {
9
10
  [pluginId: string]: GlobalPluginData;
10
11
  };
11
12
  export declare const useDocsData: (pluginId: string | undefined) => GlobalPluginData;
12
- export declare const useActivePlugin: (options?: GetActivePluginOptions) => ActivePlugin | undefined;
13
- export declare const useActivePluginAndVersion: (options?: GetActivePluginOptions) => {
13
+ export declare const useActivePlugin: (options?: UseDataOptions) => ActivePlugin | undefined;
14
+ export declare const useActivePluginAndVersion: (options?: UseDataOptions) => {
14
15
  activePlugin: ActivePlugin;
15
16
  activeVersion: GlobalVersion | undefined;
16
17
  } | undefined;
@@ -7,19 +7,20 @@
7
7
  */
8
8
  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
- const tslib_1 = require("tslib");
11
10
  const router_1 = require("@docusaurus/router");
12
- const useGlobalData_1 = tslib_1.__importStar(require("@docusaurus/useGlobalData"));
11
+ const useGlobalData_1 = require("@docusaurus/useGlobalData");
13
12
  const docsClientUtils_1 = require("./docsClientUtils");
14
13
  // Important to use a constant object to avoid React useEffect executions etc.
15
14
  // see https://github.com/facebook/docusaurus/issues/5089
16
15
  const StableEmptyObject = {};
17
- // Not using useAllPluginInstancesData() because in blog-only mode, docs hooks
18
- // are still used by the theme. We need a fail-safe fallback when the docs
19
- // plugin is not in use
20
- const useAllDocsData = () => (0, useGlobalData_1.default)()['docusaurus-plugin-content-docs'] ?? StableEmptyObject;
16
+ // In blog-only mode, docs hooks are still used by the theme. We need a fail-
17
+ // safe fallback when the docs plugin is not in use
18
+ const useAllDocsData = () => (0, useGlobalData_1.useAllPluginInstancesData)('docusaurus-plugin-content-docs') ??
19
+ StableEmptyObject;
21
20
  exports.useAllDocsData = useAllDocsData;
22
- const useDocsData = (pluginId) => (0, useGlobalData_1.usePluginData)('docusaurus-plugin-content-docs', pluginId);
21
+ const useDocsData = (pluginId) => (0, useGlobalData_1.usePluginData)('docusaurus-plugin-content-docs', pluginId, {
22
+ failfast: true,
23
+ });
23
24
  exports.useDocsData = useDocsData;
24
25
  // TODO this feature should be provided by docusaurus core
25
26
  const useActivePlugin = (options = {}) => {
package/lib/docs.js CHANGED
@@ -158,7 +158,9 @@ function doProcessDocMetadata({ docFile, versionMetadata, context, options, }) {
158
158
  lastUpdatedBy: lastUpdate.lastUpdatedBy,
159
159
  lastUpdatedAt: lastUpdate.lastUpdatedAt,
160
160
  formattedLastUpdatedAt: lastUpdate.lastUpdatedAt
161
- ? new Intl.DateTimeFormat(i18n.currentLocale).format(lastUpdate.lastUpdatedAt * 1000)
161
+ ? new Intl.DateTimeFormat(i18n.currentLocale, {
162
+ calendar: i18n.localeConfigs[i18n.currentLocale].calendar,
163
+ }).format(lastUpdate.lastUpdatedAt * 1000)
162
164
  : undefined,
163
165
  sidebarPosition,
164
166
  frontMatter,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "0.0.0-4841",
3
+ "version": "0.0.0-4844",
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-4841",
27
- "@docusaurus/logger": "0.0.0-4841",
28
- "@docusaurus/mdx-loader": "0.0.0-4841",
29
- "@docusaurus/utils": "0.0.0-4841",
30
- "@docusaurus/utils-validation": "0.0.0-4841",
26
+ "@docusaurus/core": "0.0.0-4844",
27
+ "@docusaurus/logger": "0.0.0-4844",
28
+ "@docusaurus/mdx-loader": "0.0.0-4844",
29
+ "@docusaurus/utils": "0.0.0-4844",
30
+ "@docusaurus/utils-validation": "0.0.0-4844",
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.70.1"
40
40
  },
41
41
  "devDependencies": {
42
- "@docusaurus/module-type-aliases": "0.0.0-4841",
43
- "@docusaurus/types": "0.0.0-4841",
42
+ "@docusaurus/module-type-aliases": "0.0.0-4844",
43
+ "@docusaurus/types": "0.0.0-4844",
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": "d8b0b5fbaeeb5c2f8c380816f817bd2c7b88ff85"
59
+ "gitHead": "e0f8d5729166419088bbfd857d12d063c7a53a1e"
60
60
  }
@@ -11,11 +11,11 @@ import type {
11
11
  GlobalPluginData,
12
12
  GlobalVersion,
13
13
  GlobalDoc,
14
- GetActivePluginOptions,
15
14
  ActivePlugin,
16
15
  ActiveDocContext,
17
16
  DocVersionSuggestions,
18
17
  } from '@docusaurus/plugin-content-docs/client';
18
+ import type {UseDataOptions} from '@docusaurus/types';
19
19
 
20
20
  // This code is not part of the api surface, not in ./theme on purpose
21
21
 
@@ -25,7 +25,7 @@ import type {
25
25
  export function getActivePlugin(
26
26
  allPluginData: {[pluginId: string]: GlobalPluginData},
27
27
  pathname: string,
28
- options: GetActivePluginOptions = {},
28
+ options: UseDataOptions = {},
29
29
  ): ActivePlugin | undefined {
30
30
  const activeEntry = Object.entries(allPluginData)
31
31
  // Route sorting: '/android/foo' should match '/android' instead of '/'
@@ -6,7 +6,10 @@
6
6
  */
7
7
 
8
8
  import {useLocation} from '@docusaurus/router';
9
- import useGlobalData, {usePluginData} from '@docusaurus/useGlobalData';
9
+ import {
10
+ useAllPluginInstancesData,
11
+ usePluginData,
12
+ } from '@docusaurus/useGlobalData';
10
13
 
11
14
  import {
12
15
  getActivePlugin,
@@ -21,25 +24,27 @@ import type {
21
24
  ActivePlugin,
22
25
  ActiveDocContext,
23
26
  DocVersionSuggestions,
24
- GetActivePluginOptions,
25
27
  } from '@docusaurus/plugin-content-docs/client';
28
+ import type {UseDataOptions} from '@docusaurus/types';
26
29
 
27
30
  // Important to use a constant object to avoid React useEffect executions etc.
28
31
  // see https://github.com/facebook/docusaurus/issues/5089
29
32
  const StableEmptyObject = {};
30
33
 
31
- // Not using useAllPluginInstancesData() because in blog-only mode, docs hooks
32
- // are still used by the theme. We need a fail-safe fallback when the docs
33
- // plugin is not in use
34
+ // In blog-only mode, docs hooks are still used by the theme. We need a fail-
35
+ // safe fallback when the docs plugin is not in use
34
36
  export const useAllDocsData = (): {[pluginId: string]: GlobalPluginData} =>
35
- useGlobalData()['docusaurus-plugin-content-docs'] ?? StableEmptyObject;
37
+ useAllPluginInstancesData('docusaurus-plugin-content-docs') ??
38
+ StableEmptyObject;
36
39
 
37
40
  export const useDocsData = (pluginId: string | undefined): GlobalPluginData =>
38
- usePluginData('docusaurus-plugin-content-docs', pluginId) as GlobalPluginData;
41
+ usePluginData('docusaurus-plugin-content-docs', pluginId, {
42
+ failfast: true,
43
+ }) as GlobalPluginData;
39
44
 
40
45
  // TODO this feature should be provided by docusaurus core
41
46
  export const useActivePlugin = (
42
- options: GetActivePluginOptions = {},
47
+ options: UseDataOptions = {},
43
48
  ): ActivePlugin | undefined => {
44
49
  const data = useAllDocsData();
45
50
  const {pathname} = useLocation();
@@ -47,7 +52,7 @@ export const useActivePlugin = (
47
52
  };
48
53
 
49
54
  export const useActivePluginAndVersion = (
50
- options: GetActivePluginOptions = {},
55
+ options: UseDataOptions = {},
51
56
  ):
52
57
  | undefined
53
58
  | {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined} => {
package/src/docs.ts CHANGED
@@ -254,9 +254,9 @@ function doProcessDocMetadata({
254
254
  lastUpdatedBy: lastUpdate.lastUpdatedBy,
255
255
  lastUpdatedAt: lastUpdate.lastUpdatedAt,
256
256
  formattedLastUpdatedAt: lastUpdate.lastUpdatedAt
257
- ? new Intl.DateTimeFormat(i18n.currentLocale).format(
258
- lastUpdate.lastUpdatedAt * 1000,
259
- )
257
+ ? new Intl.DateTimeFormat(i18n.currentLocale, {
258
+ calendar: i18n.localeConfigs[i18n.currentLocale]!.calendar,
259
+ }).format(lastUpdate.lastUpdatedAt * 1000)
260
260
  : undefined,
261
261
  sidebarPosition,
262
262
  frontMatter,
@@ -612,6 +612,8 @@ declare module '@theme/DocPage/Layout/Main' {
612
612
 
613
613
  // TODO until TS supports exports field... hope it's in 4.6
614
614
  declare module '@docusaurus/plugin-content-docs/client' {
615
+ import type {UseDataOptions} from '@docusaurus/types';
616
+
615
617
  export type ActivePlugin = {
616
618
  pluginId: string;
617
619
  pluginData: GlobalPluginData;
@@ -655,15 +657,14 @@ declare module '@docusaurus/plugin-content-docs/client' {
655
657
  // suggest the same doc, in latest version (if exist)
656
658
  latestDocSuggestion?: GlobalDoc;
657
659
  };
658
- export type GetActivePluginOptions = {failfast?: boolean}; // use fail-fast option if you know for sure one plugin instance is active
659
660
 
660
661
  export const useAllDocsData: () => {[pluginId: string]: GlobalPluginData};
661
662
  export const useDocsData: (pluginId?: string) => GlobalPluginData;
662
663
  export const useActivePlugin: (
663
- options?: GetActivePluginOptions,
664
+ options?: UseDataOptions,
664
665
  ) => ActivePlugin | undefined;
665
666
  export const useActivePluginAndVersion: (
666
- options?: GetActivePluginOptions,
667
+ options?: UseDataOptions,
667
668
  ) =>
668
669
  | {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
669
670
  | undefined;