-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(search): keyboard support for enter key (#1545)
* fix(search): keyboard support for enter key * chore: cleanup
- Loading branch information
1 parent
2b680ed
commit eaf0a12
Showing
3 changed files
with
21 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/gatsby-theme-carbon/src/util/convertFilePathToUrl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export function convertFilePathToUrl(filePath) { | ||
if (!filePath) return null; | ||
|
||
const pagesIndex = filePath.lastIndexOf('/pages/'); | ||
if (pagesIndex === -1) return null; | ||
|
||
const fileName = filePath.slice( | ||
pagesIndex + '/pages/'.length, | ||
filePath.lastIndexOf('.') | ||
); | ||
const normalizedFileName = fileName.endsWith('/index') | ||
? fileName.slice(0, -'/index'.length) | ||
: fileName; | ||
const urlPath = `/${normalizedFileName}/`; | ||
|
||
return urlPath; | ||
} |