gatsby-theme-carbon 4.0.8 → 4.0.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-theme-carbon",
3
- "version": "4.0.8",
3
+ "version": "4.0.9",
4
4
  "main": "index.js",
5
5
  "author": "vpicone <vp@vincepic.one> (@vpicone)",
6
6
  "repository": {
@@ -10,12 +10,14 @@ import * as styles from './LeftNavTree.module.scss';
10
10
  import { dfs } from '../../util/NavTree';
11
11
 
12
12
  import LeftNavResourceLinks from './ResourceLinks';
13
+ import usePathprefix from '../../util/hooks/usePathprefix';
13
14
 
14
15
  const LeftNavTree = ({ items, theme }) => {
15
16
  const [itemNodes, setItemNodes] = useState([]);
16
17
  const [treeActiveItem, setTreeActiveItem] = useState({});
17
18
  const [activePath, setActivePath] = useState('');
18
19
  const location = useLocation();
20
+ const pathPrefix = usePathprefix();
19
21
 
20
22
  const themeValue = theme === 'dark' ? 'g100' : theme;
21
23
 
@@ -66,7 +68,11 @@ const LeftNavTree = ({ items, theme }) => {
66
68
  useEffect(() => {
67
69
  const stripTrailingSlash = (str) =>
68
70
  str.endsWith('/') ? str.slice(0, -1) : str;
69
- setActivePath(stripTrailingSlash(location.pathname));
71
+
72
+ const base = pathPrefix
73
+ ? location.pathname.replace(pathPrefix, '')
74
+ : location.pathname;
75
+ setActivePath(stripTrailingSlash(base));
70
76
  }, [location.pathname]);
71
77
 
72
78
  const getItemPath = (item) =>