gatsby-theme-carbon 4.1.13 → 4.1.15
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.1.
|
|
3
|
+
"version": "4.1.15",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"author": "vpicone <vp@vincepic.one> (@vpicone)",
|
|
6
6
|
"repository": {
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"@babel/core": "^7.24.7",
|
|
26
26
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
27
27
|
"@babel/plugin-syntax-jsx": "^7.24.7",
|
|
28
|
-
"@carbon/elements": "^11.
|
|
28
|
+
"@carbon/elements": "^11.57.0",
|
|
29
29
|
"@carbon/grid": "^11.29.0",
|
|
30
|
-
"@carbon/pictograms-react": "^11.
|
|
31
|
-
"@carbon/react": "^1.
|
|
30
|
+
"@carbon/pictograms-react": "^11.69.0",
|
|
31
|
+
"@carbon/react": "^1.71.0",
|
|
32
32
|
"@carbon/themes": "^11.43.0",
|
|
33
33
|
"@garcia-enterprise/gatsby-plugin-sass-resources": "^4.0.2",
|
|
34
34
|
"@mdx-js/mdx": "^3.0.1",
|
|
@@ -18,6 +18,7 @@ import { graphql, navigate, useStaticQuery } from 'gatsby';
|
|
|
18
18
|
import cx from 'classnames';
|
|
19
19
|
import NavContext from '../../util/context/NavContext';
|
|
20
20
|
import { useOnClickOutside } from '../../util/hooks';
|
|
21
|
+
import { convertFilePathToUrl } from '../../util/convertFilePathToUrl';
|
|
21
22
|
|
|
22
23
|
import {
|
|
23
24
|
container,
|
|
@@ -118,7 +119,7 @@ const GlobalSearchInput = () => {
|
|
|
118
119
|
case 'Enter': {
|
|
119
120
|
e.preventDefault();
|
|
120
121
|
if (results[focusedItem]) {
|
|
121
|
-
navigate(results[focusedItem].path);
|
|
122
|
+
navigate(convertFilePathToUrl(results[focusedItem].path));
|
|
122
123
|
}
|
|
123
124
|
break;
|
|
124
125
|
}
|
|
@@ -14,6 +14,8 @@ import {
|
|
|
14
14
|
tab,
|
|
15
15
|
} from './GlobalSearch.module.scss';
|
|
16
16
|
|
|
17
|
+
import { convertFilePathToUrl } from '../../util/convertFilePathToUrl';
|
|
18
|
+
|
|
17
19
|
export const MenuContext = createContext();
|
|
18
20
|
|
|
19
21
|
const Menu = ({ results, onKeyDown }) => {
|
|
@@ -77,22 +79,6 @@ const MenuItem = ({ page, index, onKeyDown, id }) => {
|
|
|
77
79
|
[active]: focusedItem === index,
|
|
78
80
|
});
|
|
79
81
|
|
|
80
|
-
function convertFilePathToUrl(filePath) {
|
|
81
|
-
const pagesIndex = filePath.lastIndexOf('/pages/');
|
|
82
|
-
if (filePath.lastIndexOf('/pages/') === -1) return null;
|
|
83
|
-
|
|
84
|
-
const fileName = filePath.slice(
|
|
85
|
-
pagesIndex + '/pages/'.length,
|
|
86
|
-
-'.mdx'.length
|
|
87
|
-
);
|
|
88
|
-
const normalizedFileName = fileName.endsWith('/index')
|
|
89
|
-
? fileName.slice(0, -'/index'.length)
|
|
90
|
-
: fileName;
|
|
91
|
-
const urlPath = `/${normalizedFileName.split('/').join('/')}/`;
|
|
92
|
-
|
|
93
|
-
return urlPath;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
82
|
const url = convertFilePathToUrl(page.path);
|
|
97
83
|
|
|
98
84
|
return (
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function convertFilePathToUrl(filePath) {
|
|
2
|
+
if (!filePath) return null;
|
|
3
|
+
|
|
4
|
+
const pagesIndex = filePath.lastIndexOf('/pages/');
|
|
5
|
+
if (pagesIndex === -1) return null;
|
|
6
|
+
|
|
7
|
+
const fileName = filePath.slice(
|
|
8
|
+
pagesIndex + '/pages/'.length,
|
|
9
|
+
filePath.lastIndexOf('.')
|
|
10
|
+
);
|
|
11
|
+
const normalizedFileName = fileName.endsWith('/index')
|
|
12
|
+
? fileName.slice(0, -'/index'.length)
|
|
13
|
+
: fileName;
|
|
14
|
+
const urlPath = `/${normalizedFileName}/`;
|
|
15
|
+
|
|
16
|
+
return urlPath;
|
|
17
|
+
}
|