-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docs): handle ComponentExample hash names
- Loading branch information
1 parent
21069f4
commit b27f077
Showing
8 changed files
with
48 additions
and
46 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
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 was deleted.
Oops, something went wrong.
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,25 @@ | ||
import _ from 'lodash/fp' | ||
|
||
/** | ||
* Creates a short hash path from an example filename. | ||
* | ||
* Typical Hash structure ${pathname}-${section}-${exampleName} | ||
* shorten to new structure ${section} - -${exampleName without "component-example"} | ||
* @param {string} examplePath | ||
*/ | ||
const examplePathToHash = (examplePath) => { | ||
const hashParts = examplePath.split('/') | ||
|
||
if (!hashParts.length) return examplePath | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
const [type, componentName, section, exampleName] = hashParts | ||
|
||
// ButtonExampleActive => Active | ||
// PopupExample => Popup | ||
const shortExampleName = exampleName.replace(`${componentName}Example`, '') || componentName | ||
|
||
return _.kebabCase(`${section}-${shortExampleName}`) | ||
} | ||
|
||
export default examplePathToHash |
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 |
---|---|---|
@@ -1,9 +1,7 @@ | ||
import _ from 'lodash' | ||
|
||
/** | ||
* Retrieve hash string from location path | ||
* @param {string} hash | ||
*/ | ||
const getHashString = hash => _.last((hash || '').split('#')) | ||
const getHashString = hash => (hash || '').replace('#', '') | ||
|
||
export default getHashString |
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