@docusaurus/theme-common 0.0.0-4238 → 0.0.0-4243

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.
@@ -13,6 +13,10 @@ export interface StorageSlot {
13
13
  }
14
14
  /**
15
15
  * Creates an object for accessing a particular key in localStorage.
16
+ * The API is fail-safe, and usage of browser storage should be considered unreliable
17
+ * Local storage might simply be unavailable (iframe + browser security) or operations might fail individually
18
+ * Please assume that using this API can be a NO-OP
19
+ * See also https://github.com/facebook/docusaurus/issues/6036
16
20
  */
17
21
  export declare const createStorageSlot: (key: string, options?: {
18
22
  persistence?: "localStorage" | "none" | "sessionStorage" | undefined;
@@ -57,6 +57,10 @@ Please only call storage APIs in effects and event handlers.`);
57
57
  }
58
58
  /**
59
59
  * Creates an object for accessing a particular key in localStorage.
60
+ * The API is fail-safe, and usage of browser storage should be considered unreliable
61
+ * Local storage might simply be unavailable (iframe + browser security) or operations might fail individually
62
+ * Please assume that using this API can be a NO-OP
63
+ * See also https://github.com/facebook/docusaurus/issues/6036
60
64
  */
61
65
  export const createStorageSlot = (key, options) => {
62
66
  if (typeof window === 'undefined') {
@@ -67,9 +71,31 @@ export const createStorageSlot = (key, options) => {
67
71
  return NoopStorageSlot;
68
72
  }
69
73
  return {
70
- get: () => browserStorage.getItem(key),
71
- set: (value) => browserStorage.setItem(key, value),
72
- del: () => browserStorage.removeItem(key),
74
+ get: () => {
75
+ try {
76
+ return browserStorage.getItem(key);
77
+ }
78
+ catch (e) {
79
+ console.error(`Docusaurus storage error, can't get key=${key}`, e);
80
+ return null;
81
+ }
82
+ },
83
+ set: (value) => {
84
+ try {
85
+ browserStorage.setItem(key, value);
86
+ }
87
+ catch (e) {
88
+ console.error(`Docusaurus storage error, can't set ${key}=${value}`, e);
89
+ }
90
+ },
91
+ del: () => {
92
+ try {
93
+ browserStorage.removeItem(key);
94
+ }
95
+ catch (e) {
96
+ console.error(`Docusaurus storage error, can't delete key=${key}`, e);
97
+ }
98
+ },
73
99
  };
74
100
  };
75
101
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-common",
3
- "version": "0.0.0-4238",
3
+ "version": "0.0.0-4243",
4
4
  "description": "Common code for Docusaurus themes.",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -18,10 +18,10 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@docusaurus/core": "0.0.0-4238",
22
- "@docusaurus/plugin-content-blog": "0.0.0-4238",
23
- "@docusaurus/plugin-content-docs": "0.0.0-4238",
24
- "@docusaurus/plugin-content-pages": "0.0.0-4238",
21
+ "@docusaurus/core": "0.0.0-4243",
22
+ "@docusaurus/plugin-content-blog": "0.0.0-4243",
23
+ "@docusaurus/plugin-content-docs": "0.0.0-4243",
24
+ "@docusaurus/plugin-content-pages": "0.0.0-4243",
25
25
  "clsx": "^1.1.1",
26
26
  "fs-extra": "^10.0.0",
27
27
  "parse-numeric-range": "^1.3.0",
@@ -29,8 +29,9 @@
29
29
  "utility-types": "^3.10.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@docusaurus/module-type-aliases": "0.0.0-4238",
33
- "@docusaurus/types": "0.0.0-4238",
32
+ "@docusaurus/module-type-aliases": "0.0.0-4243",
33
+ "@docusaurus/types": "0.0.0-4243",
34
+ "@testing-library/react-hooks": "^7.0.2",
34
35
  "lodash": "^4.17.20"
35
36
  },
36
37
  "peerDependencies": {
@@ -41,5 +42,5 @@
41
42
  "engines": {
42
43
  "node": ">=14"
43
44
  },
44
- "gitHead": "b461d8c0ec2fcea4f614bf5eec4ca700284bb42e"
45
+ "gitHead": "9ff41c223c3422e3483bc1049ee9ec703d11e0cd"
45
46
  }
package/src/index.ts CHANGED
@@ -32,7 +32,18 @@ export {
32
32
 
33
33
  export {docVersionSearchTag, DEFAULT_SEARCH_TAG} from './utils/searchUtils';
34
34
 
35
- export {isDocsPluginEnabled} from './utils/docsUtils';
35
+ export {
36
+ isDocsPluginEnabled,
37
+ DocsVersionProvider,
38
+ useDocsVersion,
39
+ useDocById,
40
+ DocsSidebarProvider,
41
+ useDocsSidebar,
42
+ findSidebarCategory,
43
+ findFirstCategoryLink,
44
+ useCurrentSidebarCategory,
45
+ isActiveSidebarItem,
46
+ } from './utils/docsUtils';
36
47
 
37
48
  export {isSamePath} from './utils/pathUtils';
38
49
 
@@ -0,0 +1,331 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import React from 'react';
9
+ import {renderHook} from '@testing-library/react-hooks';
10
+ import {
11
+ findFirstCategoryLink,
12
+ isActiveSidebarItem,
13
+ DocsVersionProvider,
14
+ useDocsVersion,
15
+ useDocById,
16
+ useDocsSidebar,
17
+ DocsSidebarProvider,
18
+ findSidebarCategory,
19
+ } from '../docsUtils';
20
+ import {
21
+ PropSidebar,
22
+ PropSidebarItem,
23
+ PropSidebarItemCategory,
24
+ PropVersionMetadata,
25
+ } from '@docusaurus/plugin-content-docs';
26
+
27
+ // Make tests more readable with some useful category item defaults
28
+ function testCategory(
29
+ data?: Partial<PropSidebarItemCategory>,
30
+ ): PropSidebarItemCategory {
31
+ return {
32
+ type: 'category',
33
+ href: undefined,
34
+ label: 'Category label',
35
+ items: [],
36
+ collapsed: true,
37
+ collapsible: true,
38
+ ...data,
39
+ };
40
+ }
41
+
42
+ function testVersion(data?: Partial<PropVersionMetadata>): PropVersionMetadata {
43
+ return {
44
+ version: 'versionName',
45
+ label: 'Version Label',
46
+ className: 'version className',
47
+ badge: true,
48
+ banner: 'unreleased',
49
+ docs: {},
50
+ docsSidebars: {},
51
+ isLast: false,
52
+ pluginId: 'default',
53
+ ...data,
54
+ };
55
+ }
56
+
57
+ describe('docsUtils', () => {
58
+ describe('useDocsVersion', () => {
59
+ test('should throw if context provider is missing', () => {
60
+ expect(
61
+ () => renderHook(() => useDocsVersion()).result.current,
62
+ ).toThrowErrorMatchingInlineSnapshot(
63
+ `"This hook requires usage of <DocsVersionProvider>"`,
64
+ );
65
+ });
66
+
67
+ test('should read value from context provider', () => {
68
+ const version = testVersion();
69
+ const {result} = renderHook(() => useDocsVersion(), {
70
+ wrapper: ({children}) => (
71
+ <DocsVersionProvider version={version}>
72
+ {children}
73
+ </DocsVersionProvider>
74
+ ),
75
+ });
76
+ expect(result.current).toBe(version);
77
+ });
78
+ });
79
+
80
+ describe('useDocsSidebar', () => {
81
+ test('should throw if context provider is missing', () => {
82
+ expect(
83
+ () => renderHook(() => useDocsSidebar()).result.current,
84
+ ).toThrowErrorMatchingInlineSnapshot(
85
+ `"This hook requires usage of <DocsSidebarProvider>"`,
86
+ );
87
+ });
88
+
89
+ test('should read value from context provider', () => {
90
+ const sidebar: PropSidebar = [];
91
+ const {result} = renderHook(() => useDocsSidebar(), {
92
+ wrapper: ({children}) => (
93
+ <DocsSidebarProvider sidebar={sidebar}>
94
+ {children}
95
+ </DocsSidebarProvider>
96
+ ),
97
+ });
98
+ expect(result.current).toBe(sidebar);
99
+ });
100
+ });
101
+
102
+ describe('useDocById', () => {
103
+ const version = testVersion({
104
+ docs: {
105
+ doc1: {
106
+ id: 'doc1',
107
+ title: 'Doc 1',
108
+ description: 'desc1',
109
+ sidebar: 'sidebar1',
110
+ },
111
+ doc2: {
112
+ id: 'doc2',
113
+ title: 'Doc 2',
114
+ description: 'desc2',
115
+ sidebar: 'sidebar2',
116
+ },
117
+ },
118
+ });
119
+
120
+ function callHook(docId: string | undefined) {
121
+ const {result} = renderHook(() => useDocById(docId), {
122
+ wrapper: ({children}) => (
123
+ <DocsVersionProvider version={version}>
124
+ {children}
125
+ </DocsVersionProvider>
126
+ ),
127
+ });
128
+ return result.current;
129
+ }
130
+
131
+ test('should accept undefined', () => {
132
+ expect(callHook(undefined)).toBeUndefined();
133
+ });
134
+
135
+ test('should find doc1', () => {
136
+ expect(callHook('doc1')).toMatchObject({id: 'doc1'});
137
+ });
138
+ test('should find doc2', () => {
139
+ expect(callHook('doc2')).toMatchObject({id: 'doc2'});
140
+ });
141
+
142
+ test('should throw for doc3', () => {
143
+ expect(() => callHook('doc3')).toThrowErrorMatchingInlineSnapshot(
144
+ `"no version doc found by id=doc3"`,
145
+ );
146
+ });
147
+ });
148
+
149
+ describe('findSidebarCategory', () => {
150
+ test('should be able to return undefined', () => {
151
+ expect(findSidebarCategory([], () => false)).toBeUndefined();
152
+ expect(
153
+ findSidebarCategory([testCategory(), testCategory()], () => false),
154
+ ).toBeUndefined();
155
+ });
156
+
157
+ test('should return first element matching predicate', () => {
158
+ const first = testCategory();
159
+ const second = testCategory();
160
+ const third = testCategory();
161
+ const sidebar = [first, second, third];
162
+ expect(findSidebarCategory(sidebar, () => true)).toEqual(first);
163
+ expect(findSidebarCategory(sidebar, (item) => item === first)).toEqual(
164
+ first,
165
+ );
166
+ expect(findSidebarCategory(sidebar, (item) => item === second)).toEqual(
167
+ second,
168
+ );
169
+ expect(findSidebarCategory(sidebar, (item) => item === third)).toEqual(
170
+ third,
171
+ );
172
+ });
173
+
174
+ test('should be able to search in sub items', () => {
175
+ const subsub1 = testCategory();
176
+ const subsub2 = testCategory();
177
+ const sub1 = testCategory({
178
+ items: [subsub1, subsub2],
179
+ });
180
+ const sub2 = testCategory();
181
+ const parent = testCategory({
182
+ items: [sub1, sub2],
183
+ });
184
+ const sidebar = [parent];
185
+
186
+ expect(findSidebarCategory(sidebar, () => true)).toEqual(parent);
187
+ expect(findSidebarCategory(sidebar, (item) => item === sub1)).toEqual(
188
+ sub1,
189
+ );
190
+ expect(findSidebarCategory(sidebar, (item) => item === sub2)).toEqual(
191
+ sub2,
192
+ );
193
+ expect(findSidebarCategory(sidebar, (item) => item === subsub1)).toEqual(
194
+ subsub1,
195
+ );
196
+ expect(findSidebarCategory(sidebar, (item) => item === subsub2)).toEqual(
197
+ subsub2,
198
+ );
199
+ });
200
+ });
201
+
202
+ describe('findFirstCategoryLink', () => {
203
+ test('category without link nor child', () => {
204
+ expect(
205
+ findFirstCategoryLink(
206
+ testCategory({
207
+ href: undefined,
208
+ }),
209
+ ),
210
+ ).toEqual(undefined);
211
+ });
212
+
213
+ test('category with link', () => {
214
+ expect(
215
+ findFirstCategoryLink(
216
+ testCategory({
217
+ href: '/itemPath',
218
+ }),
219
+ ),
220
+ ).toEqual('/itemPath');
221
+ });
222
+
223
+ test('category with deeply nested category link', () => {
224
+ expect(
225
+ findFirstCategoryLink(
226
+ testCategory({
227
+ href: undefined,
228
+ items: [
229
+ testCategory({
230
+ href: undefined,
231
+ items: [
232
+ testCategory({
233
+ href: '/itemPath',
234
+ }),
235
+ ],
236
+ }),
237
+ ],
238
+ }),
239
+ ),
240
+ ).toEqual('/itemPath');
241
+ });
242
+
243
+ test('category with deeply nested link', () => {
244
+ expect(
245
+ findFirstCategoryLink(
246
+ testCategory({
247
+ href: undefined,
248
+ items: [
249
+ testCategory({
250
+ href: undefined,
251
+ items: [{type: 'link', href: '/itemPath', label: 'Label'}],
252
+ }),
253
+ ],
254
+ }),
255
+ ),
256
+ ).toEqual('/itemPath');
257
+ });
258
+ });
259
+
260
+ describe('isActiveSidebarItem', () => {
261
+ test('with link href', () => {
262
+ const item: PropSidebarItem = {
263
+ type: 'link',
264
+ href: '/itemPath',
265
+ label: 'Label',
266
+ };
267
+
268
+ expect(isActiveSidebarItem(item, '/unexistingPath')).toEqual(false);
269
+
270
+ expect(isActiveSidebarItem(item, '/itemPath')).toEqual(true);
271
+
272
+ // Ensure it's not trailing slash sensitive:
273
+ expect(isActiveSidebarItem(item, '/itemPath/')).toEqual(true);
274
+ expect(
275
+ isActiveSidebarItem({...item, href: '/itemPath/'}, '/itemPath'),
276
+ ).toEqual(true);
277
+ });
278
+
279
+ test('with category href', () => {
280
+ const item: PropSidebarItem = testCategory({
281
+ href: '/itemPath',
282
+ });
283
+
284
+ expect(isActiveSidebarItem(item, '/unexistingPath')).toEqual(false);
285
+
286
+ expect(isActiveSidebarItem(item, '/itemPath')).toEqual(true);
287
+
288
+ // Ensure it's not trailing slash sensitive:
289
+ expect(isActiveSidebarItem(item, '/itemPath/')).toEqual(true);
290
+ expect(
291
+ isActiveSidebarItem({...item, href: '/itemPath/'}, '/itemPath'),
292
+ ).toEqual(true);
293
+ });
294
+
295
+ test('with category nested items', () => {
296
+ const item: PropSidebarItem = testCategory({
297
+ href: '/category-path',
298
+ items: [
299
+ {
300
+ type: 'link',
301
+ href: '/sub-link-path',
302
+ label: 'Label',
303
+ },
304
+ testCategory({
305
+ href: '/sub-category-path',
306
+ items: [
307
+ {
308
+ type: 'link',
309
+ href: '/sub-sub-link-path',
310
+ label: 'Label',
311
+ },
312
+ ],
313
+ }),
314
+ ],
315
+ });
316
+
317
+ expect(isActiveSidebarItem(item, '/unexistingPath')).toEqual(false);
318
+
319
+ expect(isActiveSidebarItem(item, '/category-path')).toEqual(true);
320
+ expect(isActiveSidebarItem(item, '/sub-link-path')).toEqual(true);
321
+ expect(isActiveSidebarItem(item, '/sub-category-path')).toEqual(true);
322
+ expect(isActiveSidebarItem(item, '/sub-sub-link-path')).toEqual(true);
323
+
324
+ // Ensure it's not trailing slash sensitive:
325
+ expect(isActiveSidebarItem(item, '/category-path/')).toEqual(true);
326
+ expect(isActiveSidebarItem(item, '/sub-link-path/')).toEqual(true);
327
+ expect(isActiveSidebarItem(item, '/sub-category-path/')).toEqual(true);
328
+ expect(isActiveSidebarItem(item, '/sub-sub-link-path/')).toEqual(true);
329
+ });
330
+ });
331
+ });
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import React, {createContext, ReactNode, useContext} from 'react';
9
+ import {useAllDocsData} from '@theme/hooks/useDocs';
10
+ import {
11
+ PropSidebar,
12
+ PropSidebarItem,
13
+ PropSidebarItemCategory,
14
+ PropVersionDoc,
15
+ PropVersionMetadata,
16
+ } from '@docusaurus/plugin-content-docs';
17
+ import {isSamePath} from './pathUtils';
18
+ import {useLocation} from '@docusaurus/router';
19
+
20
+ // TODO not ideal, see also "useDocs"
21
+ export const isDocsPluginEnabled: boolean = !!useAllDocsData;
22
+
23
+ // Using a Symbol because null is a valid context value (a doc can have no sidebar)
24
+ // Inspired by https://github.com/jamiebuilds/unstated-next/blob/master/src/unstated-next.tsx
25
+ const EmptyContextValue: unique symbol = Symbol('EmptyContext');
26
+
27
+ const DocsVersionContext = createContext<
28
+ PropVersionMetadata | typeof EmptyContextValue
29
+ >(EmptyContextValue);
30
+
31
+ export function DocsVersionProvider({
32
+ children,
33
+ version,
34
+ }: {
35
+ children: ReactNode;
36
+ version: PropVersionMetadata | typeof EmptyContextValue;
37
+ }): JSX.Element {
38
+ return (
39
+ <DocsVersionContext.Provider value={version}>
40
+ {children}
41
+ </DocsVersionContext.Provider>
42
+ );
43
+ }
44
+
45
+ export function useDocsVersion(): PropVersionMetadata {
46
+ const version = useContext(DocsVersionContext);
47
+ if (version === EmptyContextValue) {
48
+ throw new Error('This hook requires usage of <DocsVersionProvider>');
49
+ }
50
+ return version;
51
+ }
52
+
53
+ export function useDocById(id: string): PropVersionDoc;
54
+ export function useDocById(id: string | undefined): PropVersionDoc | undefined;
55
+ export function useDocById(id: string | undefined): PropVersionDoc | undefined {
56
+ const version = useDocsVersion();
57
+ if (!id) {
58
+ return undefined;
59
+ }
60
+ const doc = version.docs[id];
61
+ if (!doc) {
62
+ throw new Error(`no version doc found by id=${id}`);
63
+ }
64
+ return doc;
65
+ }
66
+
67
+ const DocsSidebarContext = createContext<
68
+ PropSidebar | null | typeof EmptyContextValue
69
+ >(EmptyContextValue);
70
+
71
+ export function DocsSidebarProvider({
72
+ children,
73
+ sidebar,
74
+ }: {
75
+ children: ReactNode;
76
+ sidebar: PropSidebar | null;
77
+ }): JSX.Element {
78
+ return (
79
+ <DocsSidebarContext.Provider value={sidebar}>
80
+ {children}
81
+ </DocsSidebarContext.Provider>
82
+ );
83
+ }
84
+
85
+ export function useDocsSidebar(): PropSidebar | null {
86
+ const sidebar = useContext(DocsSidebarContext);
87
+ if (sidebar === EmptyContextValue) {
88
+ throw new Error('This hook requires usage of <DocsSidebarProvider>');
89
+ }
90
+ return sidebar;
91
+ }
92
+
93
+ // Use the components props and the sidebar in context
94
+ // to get back the related sidebar category that we want to render
95
+ export function findSidebarCategory(
96
+ sidebar: PropSidebar,
97
+ predicate: (category: PropSidebarItemCategory) => boolean,
98
+ ): PropSidebarItemCategory | undefined {
99
+ // eslint-disable-next-line no-restricted-syntax
100
+ for (const item of sidebar) {
101
+ if (item.type === 'category') {
102
+ if (predicate(item)) {
103
+ return item;
104
+ } else {
105
+ const subItem = findSidebarCategory(item.items, predicate);
106
+ if (subItem) {
107
+ return subItem;
108
+ }
109
+ }
110
+ }
111
+ }
112
+ return undefined;
113
+ }
114
+
115
+ // If a category card has no link => link to the first subItem having a link
116
+ export function findFirstCategoryLink(
117
+ item: PropSidebarItemCategory,
118
+ ): string | undefined {
119
+ if (item.href) {
120
+ return item.href;
121
+ }
122
+
123
+ // eslint-disable-next-line no-restricted-syntax
124
+ for (const subItem of item.items) {
125
+ if (subItem.type === 'link') {
126
+ return subItem.href;
127
+ }
128
+ if (subItem.type === 'category') {
129
+ const categoryLink = findFirstCategoryLink(subItem);
130
+ if (categoryLink) {
131
+ return categoryLink;
132
+ }
133
+ } else {
134
+ throw new Error(
135
+ `Unexpected category item type for ${JSON.stringify(subItem)}`,
136
+ );
137
+ }
138
+ }
139
+ return undefined;
140
+ }
141
+
142
+ export function useCurrentSidebarCategory(): PropSidebarItemCategory {
143
+ const {pathname} = useLocation();
144
+ const sidebar = useDocsSidebar();
145
+ if (!sidebar) {
146
+ throw new Error('Unexpected: cant find current sidebar in context');
147
+ }
148
+ const category = findSidebarCategory(sidebar, (item) =>
149
+ isSamePath(item.href, pathname),
150
+ );
151
+ if (!category) {
152
+ throw new Error(
153
+ `Unexpected: sidebar category could not be found for pathname='${pathname}'.
154
+ Hook useCurrentSidebarCategory() should only be used on Category pages`,
155
+ );
156
+ }
157
+ return category;
158
+ }
159
+
160
+ function containsActiveSidebarItem(
161
+ items: PropSidebarItem[],
162
+ activePath: string,
163
+ ): boolean {
164
+ return items.some((subItem) => isActiveSidebarItem(subItem, activePath));
165
+ }
166
+
167
+ export function isActiveSidebarItem(
168
+ item: PropSidebarItem,
169
+ activePath: string,
170
+ ): boolean {
171
+ const isActive = (testedPath: string | undefined) =>
172
+ typeof testedPath !== 'undefined' && isSamePath(testedPath, activePath);
173
+
174
+ if (item.type === 'link') {
175
+ return isActive(item.href);
176
+ }
177
+
178
+ if (item.type === 'category') {
179
+ return (
180
+ isActive(item.href) || containsActiveSidebarItem(item.items, activePath)
181
+ );
182
+ }
183
+
184
+ return false;
185
+ }
@@ -79,6 +79,10 @@ Please only call storage APIs in effects and event handlers.`);
79
79
 
80
80
  /**
81
81
  * Creates an object for accessing a particular key in localStorage.
82
+ * The API is fail-safe, and usage of browser storage should be considered unreliable
83
+ * Local storage might simply be unavailable (iframe + browser security) or operations might fail individually
84
+ * Please assume that using this API can be a NO-OP
85
+ * See also https://github.com/facebook/docusaurus/issues/6036
82
86
  */
83
87
  export const createStorageSlot = (
84
88
  key: string,
@@ -92,9 +96,28 @@ export const createStorageSlot = (
92
96
  return NoopStorageSlot;
93
97
  }
94
98
  return {
95
- get: () => browserStorage.getItem(key),
96
- set: (value) => browserStorage.setItem(key, value),
97
- del: () => browserStorage.removeItem(key),
99
+ get: () => {
100
+ try {
101
+ return browserStorage.getItem(key);
102
+ } catch (e) {
103
+ console.error(`Docusaurus storage error, can't get key=${key}`, e);
104
+ return null;
105
+ }
106
+ },
107
+ set: (value) => {
108
+ try {
109
+ browserStorage.setItem(key, value);
110
+ } catch (e) {
111
+ console.error(`Docusaurus storage error, can't set ${key}=${value}`, e);
112
+ }
113
+ },
114
+ del: () => {
115
+ try {
116
+ browserStorage.removeItem(key);
117
+ } catch (e) {
118
+ console.error(`Docusaurus storage error, can't delete key=${key}`, e);
119
+ }
120
+ },
98
121
  };
99
122
  };
100
123
 
@@ -1,11 +0,0 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import {useAllDocsData} from '@theme/hooks/useDocs';
9
-
10
- // TODO not ideal, see also "useDocs"
11
- export const isDocsPluginEnabled: boolean = !!useAllDocsData;