@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.
@@ -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
  */
@@ -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
  /**
@@ -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';
@@ -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-6197",
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-6197",
39
- "@docusaurus/logger": "3.7.0-canary-6197",
40
- "@docusaurus/mdx-loader": "3.7.0-canary-6197",
41
- "@docusaurus/module-type-aliases": "3.7.0-canary-6197",
42
- "@docusaurus/theme-common": "3.7.0-canary-6197",
43
- "@docusaurus/types": "3.7.0-canary-6197",
44
- "@docusaurus/utils": "3.7.0-canary-6197",
45
- "@docusaurus/utils-common": "3.7.0-canary-6197",
46
- "@docusaurus/utils-validation": "3.7.0-canary-6197",
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": "bf317203dc254101b1ba4c196e4889f4f80f9301"
70
+ "gitHead": "0fcaaf4f7747ba0367cf5474089365fd0ec0455f"
71
71
  }
@@ -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 = (
@@ -33,6 +33,7 @@ export {
33
33
  useLayoutDocsSidebar,
34
34
  useDocRootMetadata,
35
35
  useCurrentSidebarCategory,
36
+ useCurrentSidebarSiblings,
36
37
  filterDocCardListItems,
37
38
  } from './docsUtils';
38
39