@docusaurus/theme-common 2.0.0-beta.15 → 2.0.0-beta.16

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.
Files changed (107) hide show
  1. package/lib/components/Collapsible/index.d.ts.map +1 -1
  2. package/lib/components/Collapsible/index.js +9 -5
  3. package/lib/components/Collapsible/index.js.map +1 -1
  4. package/lib/components/Details/index.d.ts +1 -2
  5. package/lib/components/Details/index.d.ts.map +1 -1
  6. package/lib/components/Details/index.js +5 -4
  7. package/lib/components/Details/index.js.map +1 -1
  8. package/lib/hooks/useKeyboardNavigation.d.ts +1 -0
  9. package/lib/hooks/useKeyboardNavigation.d.ts.map +1 -1
  10. package/lib/hooks/useKeyboardNavigation.js +1 -1
  11. package/lib/hooks/useKeyboardNavigation.js.map +1 -1
  12. package/lib/hooks/useWindowSize.d.ts.map +1 -1
  13. package/lib/hooks/useWindowSize.js +4 -2
  14. package/lib/hooks/useWindowSize.js.map +1 -1
  15. package/lib/index.d.ts +4 -3
  16. package/lib/index.d.ts.map +1 -1
  17. package/lib/index.js +4 -3
  18. package/lib/index.js.map +1 -1
  19. package/lib/utils/ThemeClassNames.d.ts +1 -0
  20. package/lib/utils/ThemeClassNames.d.ts.map +1 -1
  21. package/lib/utils/ThemeClassNames.js +3 -1
  22. package/lib/utils/ThemeClassNames.js.map +1 -1
  23. package/lib/utils/codeBlockUtils.d.ts.map +1 -1
  24. package/lib/utils/codeBlockUtils.js +5 -4
  25. package/lib/utils/codeBlockUtils.js.map +1 -1
  26. package/lib/utils/colorModeUtils.d.ts.map +1 -1
  27. package/lib/utils/colorModeUtils.js +38 -16
  28. package/lib/utils/colorModeUtils.js.map +1 -1
  29. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts.map +1 -1
  30. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js +3 -7
  31. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js.map +1 -1
  32. package/lib/utils/docsUtils.d.ts +6 -1
  33. package/lib/utils/docsUtils.d.ts.map +1 -1
  34. package/lib/utils/docsUtils.js +38 -10
  35. package/lib/utils/docsUtils.js.map +1 -1
  36. package/lib/utils/historyUtils.d.ts +12 -1
  37. package/lib/utils/historyUtils.d.ts.map +1 -1
  38. package/lib/utils/historyUtils.js +9 -8
  39. package/lib/utils/historyUtils.js.map +1 -1
  40. package/lib/utils/jsUtils.d.ts +5 -2
  41. package/lib/utils/jsUtils.d.ts.map +1 -1
  42. package/lib/utils/jsUtils.js +5 -2
  43. package/lib/utils/jsUtils.js.map +1 -1
  44. package/lib/utils/mobileSecondaryMenu.d.ts.map +1 -1
  45. package/lib/utils/mobileSecondaryMenu.js.map +1 -1
  46. package/lib/utils/pathUtils.d.ts.map +1 -1
  47. package/lib/utils/pathUtils.js +7 -2
  48. package/lib/utils/pathUtils.js.map +1 -1
  49. package/lib/utils/reactUtils.d.ts +18 -0
  50. package/lib/utils/reactUtils.d.ts.map +1 -1
  51. package/lib/utils/reactUtils.js +20 -11
  52. package/lib/utils/reactUtils.js.map +1 -1
  53. package/lib/utils/regexpUtils.d.ts +1 -1
  54. package/lib/utils/regexpUtils.js +1 -1
  55. package/lib/utils/routesUtils.d.ts +11 -0
  56. package/lib/utils/routesUtils.d.ts.map +1 -0
  57. package/lib/utils/routesUtils.js +33 -0
  58. package/lib/utils/routesUtils.js.map +1 -0
  59. package/lib/utils/storageUtils.d.ts +4 -4
  60. package/lib/utils/storageUtils.d.ts.map +1 -1
  61. package/lib/utils/storageUtils.js +18 -20
  62. package/lib/utils/storageUtils.js.map +1 -1
  63. package/lib/utils/tocUtils.d.ts +9 -5
  64. package/lib/utils/tocUtils.d.ts.map +1 -1
  65. package/lib/utils/tocUtils.js +45 -7
  66. package/lib/utils/tocUtils.js.map +1 -1
  67. package/lib/utils/useAlternatePageUtils.d.ts.map +1 -1
  68. package/lib/utils/useAlternatePageUtils.js +2 -1
  69. package/lib/utils/useAlternatePageUtils.js.map +1 -1
  70. package/lib/utils/useContextualSearchFilters.js +2 -2
  71. package/lib/utils/useContextualSearchFilters.js.map +1 -1
  72. package/lib/utils/useLocationChange.d.ts +1 -1
  73. package/lib/utils/useLocationChange.d.ts.map +1 -1
  74. package/lib/utils/useLocationChange.js +3 -0
  75. package/lib/utils/useLocationChange.js.map +1 -1
  76. package/lib/utils/usePluralForm.d.ts.map +1 -1
  77. package/lib/utils/usePluralForm.js +26 -21
  78. package/lib/utils/usePluralForm.js.map +1 -1
  79. package/lib/utils/useTOCHighlight.d.ts +1 -2
  80. package/lib/utils/useTOCHighlight.d.ts.map +1 -1
  81. package/lib/utils/useTOCHighlight.js +22 -20
  82. package/lib/utils/useTOCHighlight.js.map +1 -1
  83. package/package.json +11 -11
  84. package/src/components/Collapsible/index.tsx +14 -9
  85. package/src/components/Details/index.tsx +7 -4
  86. package/src/hooks/useKeyboardNavigation.ts +2 -2
  87. package/src/hooks/useWindowSize.ts +4 -2
  88. package/src/index.ts +12 -2
  89. package/src/utils/ThemeClassNames.ts +3 -1
  90. package/src/utils/codeBlockUtils.ts +5 -4
  91. package/src/utils/colorModeUtils.tsx +39 -18
  92. package/src/utils/docsPreferredVersion/DocsPreferredVersionProvider.tsx +3 -5
  93. package/src/utils/docsUtils.tsx +56 -11
  94. package/src/utils/historyUtils.ts +10 -9
  95. package/src/utils/jsUtils.ts +5 -2
  96. package/src/utils/mobileSecondaryMenu.tsx +6 -5
  97. package/src/utils/pathUtils.ts +5 -2
  98. package/src/utils/reactUtils.tsx +20 -11
  99. package/src/utils/regexpUtils.ts +1 -1
  100. package/src/utils/routesUtils.ts +39 -0
  101. package/src/utils/storageUtils.ts +21 -19
  102. package/src/utils/tocUtils.ts +66 -13
  103. package/src/utils/useAlternatePageUtils.ts +4 -3
  104. package/src/utils/useContextualSearchFilters.ts +2 -2
  105. package/src/utils/useLocationChange.ts +5 -1
  106. package/src/utils/usePluralForm.ts +29 -23
  107. package/src/utils/useTOCHighlight.ts +24 -21
@@ -5,7 +5,43 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { useMemo } from 'react';
8
- export function filterTOC({ toc, minHeadingLevel, maxHeadingLevel, }) {
8
+ function treeifyTOC(flatTOC) {
9
+ const headings = flatTOC.map((heading) => ({
10
+ ...heading,
11
+ parentIndex: -1,
12
+ children: [],
13
+ }));
14
+ // Keep track of which previous index would be the current heading's direct
15
+ // parent. Each entry <i> is the last index of the `headings` array at heading
16
+ // level <i>. We will modify these indices as we iterate through all headings.
17
+ // e.g. if an ### H3 was last seen at index 2, then prevIndexForLevel[3] === 2
18
+ // indices 0 and 1 will remain unused.
19
+ const prevIndexForLevel = Array(7).fill(-1);
20
+ headings.forEach((curr, currIndex) => {
21
+ // take the last seen index for each ancestor level. the highest
22
+ // index will be the direct ancestor of the current heading.
23
+ const ancestorLevelIndexes = prevIndexForLevel.slice(2, curr.level);
24
+ curr.parentIndex = Math.max(...ancestorLevelIndexes);
25
+ // mark that curr.level was last seen at the current index
26
+ prevIndexForLevel[curr.level] = currIndex;
27
+ });
28
+ const rootNodes = [];
29
+ // For a given parentIndex, add each Node into that parent's `children` array
30
+ headings.forEach((heading) => {
31
+ const { parentIndex, ...rest } = heading;
32
+ if (parentIndex >= 0) {
33
+ headings[parentIndex].children.push(rest);
34
+ }
35
+ else {
36
+ rootNodes.push(rest);
37
+ }
38
+ });
39
+ return rootNodes;
40
+ }
41
+ export function useTreeifiedTOC(toc) {
42
+ return useMemo(() => treeifyTOC(toc), [toc]);
43
+ }
44
+ function filterTOC({ toc, minHeadingLevel, maxHeadingLevel, }) {
9
45
  function isValid(item) {
10
46
  return item.level >= minHeadingLevel && item.level <= maxHeadingLevel;
11
47
  }
@@ -23,13 +59,15 @@ export function filterTOC({ toc, minHeadingLevel, maxHeadingLevel, }) {
23
59
  },
24
60
  ];
25
61
  }
26
- else {
27
- return filteredChildren;
28
- }
62
+ return filteredChildren;
29
63
  });
30
64
  }
31
- // Memoize potentially expensive filtering logic
32
- export function useTOCFilter({ toc, minHeadingLevel, maxHeadingLevel, }) {
33
- return useMemo(() => filterTOC({ toc, minHeadingLevel, maxHeadingLevel }), [toc, minHeadingLevel, maxHeadingLevel]);
65
+ export function useFilteredAndTreeifiedTOC({ toc, minHeadingLevel, maxHeadingLevel, }) {
66
+ return useMemo(() =>
67
+ // Note: we have to filter the TOC after it has been treeified. This is
68
+ // mostly to ensure that weird TOC structures preserve their semantics.
69
+ // For example, an h3-h2-h4 sequence should not be treeified as an h3 > h4
70
+ // hierarchy with min=3, max=4, but should rather be [h3, h4]
71
+ filterTOC({ toc: treeifyTOC(toc), minHeadingLevel, maxHeadingLevel }), [toc, minHeadingLevel, maxHeadingLevel]);
34
72
  }
35
73
  //# sourceMappingURL=tocUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tocUtils.js","sourceRoot":"","sources":["../../src/utils/tocUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAS9B,MAAM,UAAU,SAAS,CAAC,EACxB,GAAG,EACH,eAAe,EACf,eAAe,GACA;IACf,SAAS,OAAO,CAAC,IAAa;QAC5B,OAAO,IAAI,CAAC,KAAK,IAAI,eAAe,IAAI,IAAI,CAAC,KAAK,IAAI,eAAe,CAAC;IACxE,CAAC;IAED,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC1B,MAAM,gBAAgB,GAAG,SAAS,CAAC;YACjC,GAAG,EAAE,IAAI,CAAC,QAAQ;YAClB,eAAe;YACf,eAAe;SAChB,CAAC,CAAC;QACH,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;YACjB,OAAO;gBACL;oBACE,GAAG,IAAI;oBACP,QAAQ,EAAE,gBAAgB;iBAC3B;aACF,CAAC;SACH;aAAM;YACL,OAAO,gBAAgB,CAAC;SACzB;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,YAAY,C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C,GAAG,CAAC,EAAE,eAAe,EAAE,eAAe,EAAC,CAAC,EACrE,CAAC,GAAG,EAAE,eAAe,EAAE,eAAe,CAAC,CACxC,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useAlternatePageUtils.d.ts","sourceRoot":"","sources":["../../src/utils/useAlternatePageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,wBAAgB,qBAAqB,IAAI;IACvC,SAAS,EAAE,CAAC,EACV,MAAM,EACN,cAAc,GACf,EAAE;QACD,MAAM,EAAE,MAAM,CAAC;QACf,cAAc,EAAE,OAAO,CAAC;KACzB,KAAK,MAAM,CAAC;CACd,CAoCA"}
1
+ {"version":3,"file":"useAlternatePageUtils.d.ts","sourceRoot":"","sources":["../../src/utils/useAlternatePageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,wBAAgB,qBAAqB,IAAI;IACvC,SAAS,EAAE,CAAC,EACV,MAAM,EACN,cAAc,GACf,EAAE;QACD,MAAM,EAAE,MAAM,CAAC;QACf,cAAc,EAAE,OAAO,CAAC;KACzB,KAAK,MAAM,CAAC;CACd,CAqCA"}
@@ -21,7 +21,8 @@ export function useAlternatePageUtils() {
21
21
  ? `${baseUrlUnlocalized}`
22
22
  : `${baseUrlUnlocalized}${locale}/`;
23
23
  }
24
- // TODO support correct alternate url when localized site is deployed on another domain
24
+ // TODO support correct alternate url when localized site is deployed on
25
+ // another domain
25
26
  function createUrl({ locale, fullyQualified, }) {
26
27
  return `${fullyQualified ? url : ''}${getLocalizedBaseUrl(locale)}${pathnameSuffix}`;
27
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useAlternatePageUtils.js","sourceRoot":"","sources":["../../src/utils/useAlternatePageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAE/C,kEAAkE;AAClE,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C,EAC1B,IAAI,EAAE,EAAC,aAAa,EAAE,aAAa,EAAC,GACrC,GAAG,oBAAoB,EAAE,CAAC;IAC3B,MAAM,EAAC,QAAQ,EAAC,GAAG,WAAW,EAAE,CAAC;IAEjC,MAAM,kBAAkB,GACtB,aAAa,KAAK,aAAa;QAC7B,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,aAAa,GAAG,EAAE,GAAG,CAAC,CAAC;IAEjD,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAErD,SAAS,mBAAmB,CAAC,MAAc;QACzC,OAAO,MAAM,KAAK,aAAa;YAC7B,CAAC,CAAC,GAAG,kBAAkB,EAAE;YACzB,CAAC,CAAC,GAAG,kBAAkB,GAAG,MAAM,GAAG,CAAC;IACxC,CAAC;IAED,wEAAwE;IACxE,iBAAiB;IACjB,SAAS,SAAS,CAAC,EACjB,MAAM,EACN,cAAc,GAMf;QACC,OAAO,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,mBAAmB,CACvD,MAAM,CACP,GAAG,cAAc,EAAE,CAAC;IACvB,CAAC;IAED,OAAO,EAAC,SAAS,EAAC,CAAC;AACrB,CAAC"}
@@ -8,8 +8,8 @@ import { useAllDocsData, useActivePluginAndVersion, } from '@docusaurus/plugin-c
8
8
  import { useDocsPreferredVersionByPluginId } from './docsPreferredVersion/useDocsPreferredVersion';
9
9
  import { docVersionSearchTag, DEFAULT_SEARCH_TAG } from './searchUtils';
10
10
  import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
11
- // We may want to support multiple search engines, don't couple that to Algolia/DocSearch
12
- // Maybe users will want to use its own search engine solution
11
+ // We may want to support multiple search engines, don't couple that to
12
+ // Algolia/DocSearch. Maybe users want to use their own search engine solution
13
13
  export function useContextualSearchFilters() {
14
14
  const { i18n } = useDocusaurusContext();
15
15
  const allDocsData = use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AAa,cAAb,aAAa,GAAI,gBAAgB,mCAAI,aAAa,CAAC;QAEnE,OAAO,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,IAAI,GAAG;QACX,kBAAkB;QAClB,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC;KAClD,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,aAAa;QAC1B,IAAI;KACL,CAAC;AACJ,CAAC"}
@@ -4,7 +4,7 @@
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 { Location } from '@docusaurus/history';
7
+ import type { Location } from 'history';
8
8
  declare type LocationChangeEvent = {
9
9
  location: Location;
10
10
  previousLocation: Location | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"useLocationChange.d.ts","sourceRoot":"","sources":["../../src/utils/useLocationChange.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAIlD,aAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,gBAAgB,EAAE,QAAQ,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF,aAAK,gBAAgB,GAAG,CAAC,mBAAmB,EAAE,mBAAmB,KAAK,IAAI,CAAC;AAE3E,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAc1E"}
1
+ {"version":3,"file":"useLocationChange.d.ts","sourceRoot":"","sources":["../../src/utils/useLocationChange.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAItC,aAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,gBAAgB,EAAE,QAAQ,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF,aAAK,gBAAgB,GAAG,CAAC,mBAAmB,EAAE,mBAAmB,KAAK,IAAI,CAAC;AAE3E,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAkB1E"}
@@ -13,6 +13,9 @@ export function useLocationChange(onLocationChange) {
13
13
  const previousLocation = usePrevious(location);
14
14
  const onLocationChangeDynamic = useDynamicCallback(onLocationChange);
15
15
  useEffect(() => {
16
+ if (!previousLocation) {
17
+ return;
18
+ }
16
19
  if (location !== previousLocation) {
17
20
  onLocationChangeDynamic({
18
21
  location,
@@ -1 +1 @@
1
- {"version":3,"file":"useLocationChange.js","sourceRoot":"","sources":["../../src/utils/useLocationChange.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAChC,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAShD,MAAM,UAAU,iBAAiB,CAAC,gBAAkC;IAClE,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM,gBAAgB,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IAE/C,MAAM,uBAAuB,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;IAErE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,QAAQ,KAAK,gBAAgB,EAAE;YACjC,uBAAuB,CAAC;gBACtB,QAAQ;gBACR,gBAAgB;aACjB,CAAC,CAAC;SACJ;IACH,CAAC,EAAE,CAAC,uBAAuB,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAC5D,CAAC"}
1
+ {"version":3,"file":"useLocationChange.js","sourceRoot":"","sources":["../../src/utils/useLocationChange.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAChC,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAShD,MAAM,UAAU,iBAAiB,CAAC,gBAAkC;IAClE,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM,gBAAgB,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IAE/C,MAAM,uBAAuB,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;IAErE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,gBAAgB,EAAE;YACrB,OAAO;SACR;QAED,IAAI,QAAQ,KAAK,gBAAgB,EAAE;YACjC,uBAAuB,CAAC;gBACtB,QAAQ;gBACR,gBAAgB;aACjB,CAAC,CAAC;SACJ;IACH,CAAC,EAAE,CAAC,uBAAuB,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAC5D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"usePluralForm.d.ts","sourceRoot":"","sources":["../../src/utils/usePluralForm.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwGH,wBAAgB,aAAa,IAAI;IAC/B,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,KAAK,MAAM,CAAC;CAClE,CAMA"}
1
+ {"version":3,"file":"usePluralForm.d.ts","sourceRoot":"","sources":["../../src/utils/usePluralForm.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA8GH,wBAAgB,aAAa,IAAI;IAC/B,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,KAAK,MAAM,CAAC;CAClE,CAMA"}
@@ -34,26 +34,32 @@ function createLocalePluralForms(locale) {
34
34
  select: (count) => pluralRules.select(count),
35
35
  };
36
36
  }
37
- // Poor man's PluralSelector implementation, using an english fallback.
38
- // We want a lightweight, future-proof and good-enough solution.
39
- // We don't want a perfect and heavy solution.
40
- //
41
- // Docusaurus classic theme has only 2 deeply nested labels requiring complex plural rules
42
- // We don't want to use Intl + PluralRules polyfills + full ICU syntax (react-intl) just for that.
43
- //
44
- // Notes:
45
- // - 2021: 92+% Browsers support Intl.PluralRules, and support will increase in the future
46
- // - NodeJS >= 13 has full ICU support by default
47
- // - In case of "mismatch" between SSR and Browser ICU support, React keeps working!
37
+ /**
38
+ * Poor man's PluralSelector implementation, using an english fallback. We want
39
+ * a lightweight, future-proof and good-enough solution. We don't want a perfect
40
+ * and heavy solution.
41
+ *
42
+ * Docusaurus classic theme has only 2 deeply nested labels requiring complex
43
+ * plural rules. We don't want to use Intl + PluralRules polyfills + full ICU
44
+ * syntax (react-intl) just for that.
45
+ *
46
+ * Notes:
47
+ * - 2021: 92+% Browsers support Intl.PluralRules, and support will increase in
48
+ * the future
49
+ * - NodeJS >= 13 has full ICU support by default
50
+ * - In case of "mismatch" between SSR and Browser ICU support, React keeps
51
+ * working!
52
+ */
48
53
  function useLocalePluralForms() {
49
54
  const { i18n: { currentLocale }, } = useDocusaurusContext();
50
55
  return useMemo(() => {
51
- // @ts-expect-error checking Intl.PluralRules in case browser doesn't have it (e.g Safari 12-)
56
+ // @ts-expect-error checking Intl.PluralRules in case browser doesn't
57
+ // have it (e.g Safari 12-)
52
58
  if (Intl.PluralRules) {
53
59
  try {
54
60
  return createLocalePluralForms(currentLocale);
55
61
  }
56
- catch (e) {
62
+ catch {
57
63
  console.error(`Failed to use Intl.PluralRules for locale "${currentLocale}".
58
64
  Docusaurus will fallback to a default/fallback (English) Intl.PluralRules implementation.
59
65
  `);
@@ -74,15 +80,14 @@ function selectPluralMessage(pluralMessages, count, localePluralForms) {
74
80
  if (parts.length === 1) {
75
81
  return parts[0];
76
82
  }
77
- else {
78
- if (parts.length > localePluralForms.pluralForms.length) {
79
- console.error(`For locale=${localePluralForms.locale}, a maximum of ${localePluralForms.pluralForms.length} plural forms are expected (${localePluralForms.pluralForms}), but the message contains ${parts.length} plural forms: ${pluralMessages} `);
80
- }
81
- const pluralForm = localePluralForms.select(count);
82
- const pluralFormIndex = localePluralForms.pluralForms.indexOf(pluralForm);
83
- // In case of not enough plural form messages, we take the last one (other) instead of returning undefined
84
- return parts[Math.min(pluralFormIndex, parts.length - 1)];
83
+ if (parts.length > localePluralForms.pluralForms.length) {
84
+ console.error(`For locale=${localePluralForms.locale}, a maximum of ${localePluralForms.pluralForms.length} plural forms are expected (${localePluralForms.pluralForms}), but the message contains ${parts.length} plural forms: ${pluralMessages} `);
85
85
  }
86
+ const pluralForm = localePluralForms.select(count);
87
+ const pluralFormIndex = localePluralForms.pluralForms.indexOf(pluralForm);
88
+ // In case of not enough plural form messages, we take the last one (other)
89
+ // instead of returning undefined
90
+ return parts[Math.min(pluralFormIndex, parts.length - 1)];
86
91
  }
87
92
  export function usePluralForm() {
88
93
  const localePluralForm = useLocalePluralForms();
@@ -1 +1 @@
1
- {"version":3,"file":"usePluralForm.js","sourceRoot":"","sources":["../../src/utils/usePluralForm.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAC9B,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AAEpE,6DAA6D;AAC7D,mEAAmE;AACnE,qEAAqE;AACrE,MAAM,kBAAkB,GAA0B;IAChD,MAAM;IACN,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,OAAO;CACR,CAAC;AACF,SAAS,eAAe,CACtB,WAAkC;IAElC,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AACrE,CAAC;AAQD,4CAA4C;AAC5C,MAAM,kBAAkB,GAAsB;IAC5C,MAAM,EAAE,IAAI;IACZ,WAAW,EAAE,eAAe,CAAC,CAAC,KA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{
10
10
  minHeadingLevel: number;
11
11
  maxHeadingLevel: number;
12
12
  };
13
- declare function useTOCHighlight(config: TOCHighlightConfig | undefined): void;
14
- export default useTOCHighlight;
13
+ export default function useTOCHighlight(config: TOCHighlightConfig | undefined): void;
15
14
  //# sourceMappingURL=useTOCHighlight.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTOCHighlight.d.ts","sourceRoot":"","sources":["../../src/utils/useTOCHighlight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA6GH,oBAAY,kBAAkB,GAAG;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,iBAAS,eAAe,CAAC,MAAM,EAAE,kBAAkB,GAAG,SAAS,GAAG,IAAI,CAwDrE;AAED,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"useTOCHighlight.d.ts","sourceRoot":"","sources":["../../src/utils/useTOCHighlight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgHH,oBAAY,kBAAkB,GAAG;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,MAAM,EAAE,kBAAkB,GAAG,SAAS,GACrC,IAAI,CAwDN"}
@@ -10,7 +10,8 @@ import { useThemeConfig } from './useThemeConfig';
10
10
  TODO make the hardcoded theme-classic classnames configurable
11
11
  (or add them to ThemeClassNames?)
12
12
  */
13
- // If the anchor has no height and is just a "marker" in the dom; we'll use the parent (normally the link text) rect boundaries instead
13
+ // If the anchor has no height and is just a "marker" in the dom; we'll use the
14
+ // parent (normally the link text) rect boundaries instead
14
15
  function getVisibleBoundingClientRect(element) {
15
16
  const rect = element.getBoundingClientRect();
16
17
  const hasNoHeight = rect.top === rect.bottom;
@@ -19,8 +20,10 @@ function getVisibleBoundingClientRect(element) {
19
20
  }
20
21
  return rect;
21
22
  }
22
- // Considering we divide viewport into 2 zones of each 50vh
23
- // This returns true if an element is in the first zone (ie, appear in viewport, near the top)
23
+ /**
24
+ * Considering we divide viewport into 2 zones of each 50vh, this returns true
25
+ * if an element is in the first zone (ie, appear in viewport, near the top)
26
+ */
24
27
  function isInViewportTopHalf(boundingRect) {
25
28
  return boundingRect.top > 0 && boundingRect.bottom < window.innerHeight / 2;
26
29
  }
@@ -33,32 +36,32 @@ function getAnchors({ minHeadingLevel, maxHeadingLevel, }) {
33
36
  }
34
37
  function getActiveAnchor(anchors, { anchorTopOffset, }) {
35
38
  var _a;
36
- // Naming is hard
37
- // The "nextVisibleAnchor" is the first anchor that appear under the viewport top boundary
38
- // Note: it does not mean this anchor is visible yet, but if user continues scrolling down, it will be the first to become visible
39
+ // Naming is hard: The "nextVisibleAnchor" is the first anchor that appear
40
+ // under the viewport top boundary. It does not mean this anchor is visible
41
+ // yet, but if user continues scrolling down, it will be the first to become
42
+ // visible
39
43
  const nextVisibleAnchor = anchors.find((anchor) => {
40
44
  const boundingRect = getVisibleBoundingClientRect(anchor);
41
45
  return boundingRect.top >= anchorTopOffset;
42
46
  });
43
47
  if (nextVisibleAnchor) {
44
48
  const boundingRect = getVisibleBoundingClientRect(nextVisibleAnchor);
45
- // If anchor is in the top half of the viewport: it is the one we consider "active"
46
- // (unless it's too close to the top and and soon to be scrolled outside viewport)
49
+ // If anchor is in the top half of the viewport: it is the one we consider
50
+ // "active" (unless it's too close to the top and and soon to be scrolled
51
+ // outside viewport)
47
52
  if (isInViewportTopHalf(boundingRect)) {
48
53
  return nextVisibleAnchor;
49
54
  }
50
- // If anchor is in the bottom half of the viewport, or under the viewport, we consider the active anchor is the previous one
51
- // This is because the main text appearing in the user screen mostly belong to the previous anchor
52
- else {
53
- // Returns null for the first anchor, see https://github.com/facebook/docusaurus/issues/5318
54
- return (_a = anchors[anchors.indexOf(nextVisibleAnchor) - 1]) !== null && _a !== void 0 ? _a : null;
55
- }
55
+ // If anchor is in the bottom half of the viewport, or under the viewport,
56
+ // we consider the active anchor is the previous one. This is because the
57
+ // main text appearing in the user screen mostly belong to the previous
58
+ // anchor. Returns null for the first anchor, see
59
+ // https://github.com/facebook/docusaurus/issues/5318
60
+ return (_a = anchors[anchors.indexOf(nextVisibleAnchor) - 1]) !== null && _a !== void 0 ? _a : null;
56
61
  }
57
62
  // no anchor under viewport top? (ie we are at the bottom of the page)
58
63
  // => highlight the last anchor found
59
- else {
60
- return anchors[anchors.length - 1];
61
- }
64
+ return anchors[anchors.length - 1];
62
65
  }
63
66
  function getLinkAnchorValue(link) {
64
67
  return decodeURIComponent(link.href.substring(link.href.indexOf('#') + 1));
@@ -79,7 +82,7 @@ function useAnchorTopOffsetRef() {
79
82
  }, [hideOnScroll]);
80
83
  return anchorTopOffsetRef;
81
84
  }
82
- function useTOCHighlight(config) {
85
+ export default function useTOCHighlight(config) {
83
86
  const lastActiveLinkRef = useRef(undefined);
84
87
  const anchorTopOffsetRef = useAnchorTopOffsetRef();
85
88
  useEffect(() => {
@@ -96,7 +99,7 @@ function useTOCHighlight(config) {
96
99
  }
97
100
  link.classList.add(linkActiveClassName);
98
101
  lastActiveLinkRef.current = link;
99
- link.scrollIntoView({ block: 'nearest' });
102
+ // link.scrollIntoView({block: 'nearest'});
100
103
  }
101
104
  else {
102
105
  link.classList.remove(linkActiveClassName);
@@ -122,5 +125,4 @@ function useTOCHighlight(config) {
122
125
  };
123
126
  }, [config, anchorTopOffsetRef]);
124
127
  }
125
- export default useTOCHighlight;
126
128
  //# sourceMappingURL=useTOCHighlight.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTOCHighlight.js","sourceRoot":"","sources":["../../src/utils/useTOCHighlight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,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AAgB,EAAE,CAAC;QAEnB,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;YACzD,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAC3D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;AACnC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-common",
3
- "version": "2.0.0-beta.15",
3
+ "version": "2.0.0-beta.16",
4
4
  "description": "Common code for Docusaurus themes.",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -18,29 +18,29 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@docusaurus/plugin-content-blog": "2.0.0-beta.15",
22
- "@docusaurus/plugin-content-docs": "2.0.0-beta.15",
23
- "@docusaurus/plugin-content-pages": "2.0.0-beta.15",
21
+ "@docusaurus/module-type-aliases": "2.0.0-beta.16",
22
+ "@docusaurus/plugin-content-blog": "2.0.0-beta.16",
23
+ "@docusaurus/plugin-content-docs": "2.0.0-beta.16",
24
+ "@docusaurus/plugin-content-pages": "2.0.0-beta.16",
24
25
  "clsx": "^1.1.1",
25
26
  "parse-numeric-range": "^1.3.0",
27
+ "prism-react-renderer": "^1.3.1",
26
28
  "tslib": "^2.3.1",
27
29
  "utility-types": "^3.10.0"
28
30
  },
29
31
  "devDependencies": {
30
- "@docusaurus/core": "2.0.0-beta.15",
31
- "@docusaurus/module-type-aliases": "2.0.0-beta.15",
32
- "@docusaurus/types": "2.0.0-beta.15",
32
+ "@docusaurus/core": "2.0.0-beta.16",
33
+ "@docusaurus/types": "2.0.0-beta.16",
33
34
  "@testing-library/react-hooks": "^7.0.2",
34
- "fs-extra": "^10.0.0",
35
- "lodash": "^4.17.20"
35
+ "fs-extra": "^10.0.1",
36
+ "lodash": "^4.17.21"
36
37
  },
37
38
  "peerDependencies": {
38
- "prism-react-renderer": "^1.2.1",
39
39
  "react": "^16.8.4 || ^17.0.0",
40
40
  "react-dom": "^16.8.4 || ^17.0.0"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=14"
44
44
  },
45
- "gitHead": "6cfad16436c07d8d11e5c2e1486dc59afd483e33"
45
+ "gitHead": "eb43c4d4f95a4fb97dc9bb9dc615413e0dc2e1e7"
46
46
  }
@@ -67,7 +67,8 @@ function applyCollapsedStyle(el: HTMLElement, collapsed: boolean) {
67
67
  }
68
68
 
69
69
  /*
70
- Lex111: Dynamic transition duration is used in Material design, this technique is good for a large number of items.
70
+ Lex111: Dynamic transition duration is used in Material design, this technique
71
+ is good for a large number of items.
71
72
  https://material.io/archive/guidelines/motion/duration-easing.html#duration-easing-dynamic-durations
72
73
  https://github.com/mui-org/material-ui/blob/e724d98eba018e55e1a684236a2037e24bcf050c/packages/material-ui/src/styles/createTransitions.js#L40-L43
73
74
  */
@@ -151,7 +152,8 @@ type CollapsibleElementType = React.ElementType<
151
152
  Pick<React.HTMLAttributes<unknown>, 'className' | 'onTransitionEnd' | 'style'>
152
153
  >;
153
154
 
154
- // Prevent hydration layout shift before animations are handled imperatively with JS
155
+ // Prevent hydration layout shift before animations are handled imperatively
156
+ // with JS
155
157
  function getSSRStyle(collapsed: boolean) {
156
158
  if (ExecutionEnvironment.canUseDOM) {
157
159
  return undefined;
@@ -167,8 +169,9 @@ type CollapsibleBaseProps = {
167
169
  onCollapseTransitionEnd?: (collapsed: boolean) => void;
168
170
  className?: string;
169
171
 
170
- // This is mostly useful for details/summary component where ssrStyle is not needed (as details are hidden natively)
171
- // and can mess-up with the default native behavior of the browser when JS fails to load or is disabled
172
+ // This is mostly useful for details/summary component where ssrStyle is not
173
+ // needed (as details are hidden natively) and can mess up with the default
174
+ // native behavior of the browser when JS fails to load or is disabled
172
175
  disableSSRStyle?: boolean;
173
176
  };
174
177
 
@@ -189,7 +192,8 @@ function CollapsibleBase({
189
192
 
190
193
  return (
191
194
  <As
192
- // @ts-expect-error: the "too complicated type" is produced from "CollapsibleElementType" being a huge union
195
+ // @ts-expect-error: the "too complicated type" is produced from
196
+ // "CollapsibleElementType" being a huge union
193
197
  ref={collapsibleRef}
194
198
  style={disableSSRStyle ? undefined : getSSRStyle(collapsed)}
195
199
  onTransitionEnd={(e: React.TransitionEvent) => {
@@ -215,7 +219,7 @@ function CollapsibleLazy({collapsed, ...props}: CollapsibleBaseProps) {
215
219
  }
216
220
  }, [collapsed]);
217
221
 
218
- // lazyCollapsed updated in effect so that the first expansion transition can work
222
+ // lazyCollapsed updated in effect so that first expansion transition can work
219
223
  const [lazyCollapsed, setLazyCollapsed] = useState(collapsed);
220
224
  useLayoutEffect(() => {
221
225
  if (mounted) {
@@ -229,9 +233,10 @@ function CollapsibleLazy({collapsed, ...props}: CollapsibleBaseProps) {
229
233
  }
230
234
 
231
235
  type CollapsibleProps = CollapsibleBaseProps & {
232
- // Lazy allows to delay the rendering when collapsed => it will render children only after hydration, on first expansion
233
- // Required prop: it forces to think if content should be server-rendered or not!
234
- // This has perf impact on the SSR output and html file sizes
236
+ // Lazy allows to delay the rendering when collapsed => it will render
237
+ // children only after hydration, on first expansion
238
+ // Required prop: it forces to think if content should be server-rendered
239
+ // or not! This has perf impact on the SSR output and html file sizes
235
240
  // See https://github.com/facebook/docusaurus/issues/4753
236
241
  lazy: boolean;
237
242
  };
@@ -34,18 +34,23 @@ export type DetailsProps = {
34
34
  summary?: ReactElement;
35
35
  } & ComponentProps<'details'>;
36
36
 
37
- function Details({summary, children, ...props}: DetailsProps): JSX.Element {
37
+ export default function Details({
38
+ summary,
39
+ children,
40
+ ...props
41
+ }: DetailsProps): JSX.Element {
38
42
  const isBrowser = useIsBrowser();
39
43
  const detailsRef = useRef<HTMLDetailsElement>(null);
40
44
 
41
45
  const {collapsed, setCollapsed} = useCollapsible({
42
46
  initialState: !props.open,
43
47
  });
44
- // We use a separate prop because it must be set only after animation completes
48
+ // Use a separate prop because it must be set only after animation completes
45
49
  // Otherwise close anim won't work
46
50
  const [open, setOpen] = useState(props.open);
47
51
 
48
52
  return (
53
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
49
54
  <details
50
55
  {...props}
51
56
  ref={detailsRef}
@@ -95,5 +100,3 @@ function Details({summary, children, ...props}: DetailsProps): JSX.Element {
95
100
  </details>
96
101
  );
97
102
  }
98
-
99
- export default Details;
@@ -9,12 +9,12 @@ import {useEffect} from 'react';
9
9
 
10
10
  import './styles.css';
11
11
 
12
+ export const keyboardFocusedClassName = 'navigation-with-keyboard';
13
+
12
14
  // This hook detect keyboard focus indicator to not show outline for mouse users
13
15
  // Inspired by https://hackernoon.com/removing-that-ugly-focus-ring-and-keeping-it-too-6c8727fefcd2
14
16
  export default function useKeyboardNavigation(): void {
15
17
  useEffect(() => {
16
- const keyboardFocusedClassName = 'navigation-with-keyboard';
17
-
18
18
  function handleOutlineStyles(e: MouseEvent | KeyboardEvent) {
19
19
  if (e.type === 'keydown' && (e as KeyboardEvent).key === 'Tab') {
20
20
  document.body.classList.add(keyboardFocusedClassName);
@@ -15,7 +15,8 @@ const windowSizes = {
15
15
 
16
16
  // This "ssr" value is very important to handle hydration FOUC / layout shifts
17
17
  // You have to handle server-rendering explicitly on the call-site
18
- // On the server, you may need to render BOTH the mobile/desktop elements (and hide one of them with mediaquery)
18
+ // On the server, you may need to render BOTH the mobile/desktop elements (and
19
+ // hide one of them with mediaquery)
19
20
  // We don't return "undefined" on purpose, to make it more explicit
20
21
  ssr: 'ssr',
21
22
  } as const;
@@ -33,7 +34,8 @@ function getWindowSize() {
33
34
  : windowSizes.mobile;
34
35
  }
35
36
 
36
- // Simulate the SSR window size in dev, so that potential hydration FOUC/layout shift problems can be seen in dev too!
37
+ // Simulate the SSR window size in dev, so that potential hydration FOUC/layout
38
+ // shift problems can be seen in dev too!
37
39
  const DevSimulateSSR = process.env.NODE_ENV === 'development' && true;
38
40
 
39
41
  // This hook returns an enum value on purpose!
package/src/index.ts CHANGED
@@ -49,6 +49,7 @@ export {
49
49
  findFirstCategoryLink,
50
50
  useCurrentSidebarCategory,
51
51
  isActiveSidebarItem,
52
+ useSidebarBreadcrumbs,
52
53
  } from './utils/docsUtils';
53
54
 
54
55
  export {isSamePath} from './utils/pathUtils';
@@ -103,7 +104,11 @@ export {useHistoryPopHandler} from './utils/historyUtils';
103
104
  export {default as useTOCHighlight} from './utils/useTOCHighlight';
104
105
  export type {TOCHighlightConfig} from './utils/useTOCHighlight';
105
106
 
106
- export {useTOCFilter} from './utils/tocUtils';
107
+ export {
108
+ useFilteredAndTreeifiedTOC,
109
+ useTreeifiedTOC,
110
+ type TOCTreeNode,
111
+ } from './utils/tocUtils';
107
112
 
108
113
  export {
109
114
  ScrollControllerProvider,
@@ -119,6 +124,8 @@ export {
119
124
 
120
125
  export {isRegexpStringMatch} from './utils/regexpUtils';
121
126
 
127
+ export {useHomePageRoute} from './utils/routesUtils';
128
+
122
129
  export {useColorMode, ColorModeProvider} from './utils/colorModeUtils';
123
130
  export {
124
131
  useTabGroupChoice,
@@ -126,7 +133,10 @@ export {
126
133
  } from './utils/tabGroupChoiceUtils';
127
134
 
128
135
  export {default as useHideableNavbar} from './hooks/useHideableNavbar';
129
- export {default as useKeyboardNavigation} from './hooks/useKeyboardNavigation';
136
+ export {
137
+ default as useKeyboardNavigation,
138
+ keyboardFocusedClassName,
139
+ } from './hooks/useKeyboardNavigation';
130
140
  export {default as usePrismTheme} from './hooks/usePrismTheme';
131
141
  export {default as useLockBodyScroll} from './hooks/useLockBodyScroll';
132
142
  export {default as useWindowSize} from './hooks/useWindowSize';
@@ -7,7 +7,8 @@
7
7
 
8
8
  // These class names are used to style page layouts in Docusaurus
9
9
  // Those are meant to be targeted by user-provided custom CSS selectors
10
- // /!\ Please do not modify the classnames! This is a breaking change, and annoying for users!
10
+ // Please do not modify the classnames! This is a breaking change, and annoying
11
+ // for users!
11
12
  export const ThemeClassNames = {
12
13
  page: {
13
14
  blogListPage: 'blog-list-page',
@@ -42,6 +43,7 @@ export const ThemeClassNames = {
42
43
  docs: {
43
44
  docVersionBanner: 'theme-doc-version-banner',
44
45
  docVersionBadge: 'theme-doc-version-badge',
46
+ docBreadcrumbs: 'theme-doc-breadcrumbs',
45
47
  docMarkdown: 'theme-doc-markdown',
46
48
  docTocMobile: 'theme-doc-toc-mobile',
47
49
  docTocDesktop: 'theme-doc-toc-desktop',