@docusaurus/plugin-content-docs 3.7.0-canary-6197 → 3.7.0-canary-6200
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.
- package/lib/client/docsUtils.d.ts +5 -0
- package/lib/client/docsUtils.js +18 -0
- package/lib/client/index.d.ts +1 -1
- package/lib/client/index.js +1 -1
- package/package.json +11 -11
- package/src/client/docsUtils.tsx +19 -0
- package/src/client/index.ts +1 -0
|
@@ -34,6 +34,11 @@ export declare function findFirstSidebarItemLink(item: PropSidebarItem): string
|
|
|
34
34
|
* on category index pages.
|
|
35
35
|
*/
|
|
36
36
|
export declare function useCurrentSidebarCategory(): PropSidebarItemCategory;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the category associated with the current location. Should only be used
|
|
39
|
+
* on category index pages.
|
|
40
|
+
*/
|
|
41
|
+
export declare function useCurrentSidebarSiblings(): PropSidebarItem[];
|
|
37
42
|
/**
|
|
38
43
|
* Checks if a sidebar item should be active, based on the active path.
|
|
39
44
|
*/
|
package/lib/client/docsUtils.js
CHANGED
|
@@ -91,6 +91,24 @@ export function useCurrentSidebarCategory() {
|
|
|
91
91
|
}
|
|
92
92
|
return deepestCategory;
|
|
93
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Gets the category associated with the current location. Should only be used
|
|
96
|
+
* on category index pages.
|
|
97
|
+
*/
|
|
98
|
+
export function useCurrentSidebarSiblings() {
|
|
99
|
+
const { pathname } = useLocation();
|
|
100
|
+
const sidebar = useDocsSidebar();
|
|
101
|
+
if (!sidebar) {
|
|
102
|
+
throw new Error('Unexpected: cant find current sidebar in context');
|
|
103
|
+
}
|
|
104
|
+
const categoryBreadcrumbs = getSidebarBreadcrumbs({
|
|
105
|
+
sidebarItems: sidebar.items,
|
|
106
|
+
pathname,
|
|
107
|
+
onlyCategories: true,
|
|
108
|
+
});
|
|
109
|
+
const deepestCategory = categoryBreadcrumbs.slice(-1)[0];
|
|
110
|
+
return deepestCategory?.items ?? sidebar.items;
|
|
111
|
+
}
|
|
94
112
|
const isActive = (testedPath, activePath) => typeof testedPath !== 'undefined' && isSamePath(testedPath, activePath);
|
|
95
113
|
const containsActiveSidebarItem = (items, activePath) => items.some((subItem) => isActiveSidebarItem(subItem, activePath));
|
|
96
114
|
/**
|
package/lib/client/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { UseDataOptions } from '@docusaurus/types';
|
|
8
|
-
export { useDocById, findSidebarCategory, findFirstSidebarItemLink, isActiveSidebarItem, isVisibleSidebarItem, useVisibleSidebarItems, useSidebarBreadcrumbs, useDocsVersionCandidates, useLayoutDoc, useLayoutDocsSidebar, useDocRootMetadata, useCurrentSidebarCategory, filterDocCardListItems, } from './docsUtils';
|
|
8
|
+
export { useDocById, findSidebarCategory, findFirstSidebarItemLink, isActiveSidebarItem, isVisibleSidebarItem, useVisibleSidebarItems, useSidebarBreadcrumbs, useDocsVersionCandidates, useLayoutDoc, useLayoutDocsSidebar, useDocRootMetadata, useCurrentSidebarCategory, useCurrentSidebarSiblings, filterDocCardListItems, } from './docsUtils';
|
|
9
9
|
export { useDocsPreferredVersion } from './docsPreferredVersion';
|
|
10
10
|
export { DocSidebarItemsExpandedStateProvider, useDocSidebarItemsExpandedState, } from './docSidebarItemsExpandedState';
|
|
11
11
|
export { DocsVersionProvider, useDocsVersion } from './docsVersion';
|
package/lib/client/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { useLocation } from '@docusaurus/router';
|
|
8
8
|
import { useAllPluginInstancesData, usePluginData, } from '@docusaurus/useGlobalData';
|
|
9
9
|
import { getActivePlugin, getLatestVersion, getActiveVersion, getActiveDocContext, getDocVersionSuggestions, } from './docsClientUtils';
|
|
10
|
-
export { useDocById, findSidebarCategory, findFirstSidebarItemLink, isActiveSidebarItem, isVisibleSidebarItem, useVisibleSidebarItems, useSidebarBreadcrumbs, useDocsVersionCandidates, useLayoutDoc, useLayoutDocsSidebar, useDocRootMetadata, useCurrentSidebarCategory, filterDocCardListItems, } from './docsUtils';
|
|
10
|
+
export { useDocById, findSidebarCategory, findFirstSidebarItemLink, isActiveSidebarItem, isVisibleSidebarItem, useVisibleSidebarItems, useSidebarBreadcrumbs, useDocsVersionCandidates, useLayoutDoc, useLayoutDocsSidebar, useDocRootMetadata, useCurrentSidebarCategory, useCurrentSidebarSiblings, filterDocCardListItems, } from './docsUtils';
|
|
11
11
|
export { useDocsPreferredVersion } from './docsPreferredVersion';
|
|
12
12
|
export { DocSidebarItemsExpandedStateProvider, useDocSidebarItemsExpandedState, } from './docSidebarItemsExpandedState';
|
|
13
13
|
export { DocsVersionProvider, useDocsVersion } from './docsVersion';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-docs",
|
|
3
|
-
"version": "3.7.0-canary-
|
|
3
|
+
"version": "3.7.0-canary-6200",
|
|
4
4
|
"description": "Docs plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
},
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@docusaurus/core": "3.7.0-canary-
|
|
39
|
-
"@docusaurus/logger": "3.7.0-canary-
|
|
40
|
-
"@docusaurus/mdx-loader": "3.7.0-canary-
|
|
41
|
-
"@docusaurus/module-type-aliases": "3.7.0-canary-
|
|
42
|
-
"@docusaurus/theme-common": "3.7.0-canary-
|
|
43
|
-
"@docusaurus/types": "3.7.0-canary-
|
|
44
|
-
"@docusaurus/utils": "3.7.0-canary-
|
|
45
|
-
"@docusaurus/utils-common": "3.7.0-canary-
|
|
46
|
-
"@docusaurus/utils-validation": "3.7.0-canary-
|
|
38
|
+
"@docusaurus/core": "3.7.0-canary-6200",
|
|
39
|
+
"@docusaurus/logger": "3.7.0-canary-6200",
|
|
40
|
+
"@docusaurus/mdx-loader": "3.7.0-canary-6200",
|
|
41
|
+
"@docusaurus/module-type-aliases": "3.7.0-canary-6200",
|
|
42
|
+
"@docusaurus/theme-common": "3.7.0-canary-6200",
|
|
43
|
+
"@docusaurus/types": "3.7.0-canary-6200",
|
|
44
|
+
"@docusaurus/utils": "3.7.0-canary-6200",
|
|
45
|
+
"@docusaurus/utils-common": "3.7.0-canary-6200",
|
|
46
|
+
"@docusaurus/utils-validation": "3.7.0-canary-6200",
|
|
47
47
|
"@types/react-router-config": "^5.0.7",
|
|
48
48
|
"combine-promises": "^1.1.0",
|
|
49
49
|
"fs-extra": "^11.1.1",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"engines": {
|
|
68
68
|
"node": ">=18.0"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "0fcaaf4f7747ba0367cf5474089365fd0ec0455f"
|
|
71
71
|
}
|
package/src/client/docsUtils.tsx
CHANGED
|
@@ -132,6 +132,25 @@ export function useCurrentSidebarCategory(): PropSidebarItemCategory {
|
|
|
132
132
|
return deepestCategory;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Gets the category associated with the current location. Should only be used
|
|
137
|
+
* on category index pages.
|
|
138
|
+
*/
|
|
139
|
+
export function useCurrentSidebarSiblings(): PropSidebarItem[] {
|
|
140
|
+
const {pathname} = useLocation();
|
|
141
|
+
const sidebar = useDocsSidebar();
|
|
142
|
+
if (!sidebar) {
|
|
143
|
+
throw new Error('Unexpected: cant find current sidebar in context');
|
|
144
|
+
}
|
|
145
|
+
const categoryBreadcrumbs = getSidebarBreadcrumbs({
|
|
146
|
+
sidebarItems: sidebar.items,
|
|
147
|
+
pathname,
|
|
148
|
+
onlyCategories: true,
|
|
149
|
+
});
|
|
150
|
+
const deepestCategory = categoryBreadcrumbs.slice(-1)[0];
|
|
151
|
+
return deepestCategory?.items ?? sidebar.items;
|
|
152
|
+
}
|
|
153
|
+
|
|
135
154
|
const isActive = (testedPath: string | undefined, activePath: string) =>
|
|
136
155
|
typeof testedPath !== 'undefined' && isSamePath(testedPath, activePath);
|
|
137
156
|
const containsActiveSidebarItem = (
|