This repository has been archived by the owner on Apr 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Edwin
committed
Feb 14, 2020
1 parent
8e6a622
commit f1a49e8
Showing
6 changed files
with
59 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
# Wonderbly Design System | ||
|
||
Wonderbly is growing, a lot. One of the challenges facing us as the business evolves is maintaining a consistent, cohesive and captivating experience across our digital ecosystem. We’ve been working to create this design system as a centralised hub for showcasing our design rules, principles, and frontend components. It’s a place for people familiar with the Wonderbly ecosystem, and for anyone wishing to learn more about our work. | ||
|
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,20 @@ | ||
import get from 'lodash/get'; | ||
|
||
const getTitleFromMarkdown = (markdown, removeMarkdownSigniture = false) => { | ||
const content = get(markdown, '[0].content'); | ||
|
||
if (!content) { | ||
return null; | ||
} | ||
|
||
const startsWithOneHashRegex = /^#( |\w)+/g; | ||
const titleFromMarkdown = (content.match(startsWithOneHashRegex) || [''])[0]; | ||
|
||
if (!removeMarkdownSigniture) { | ||
return titleFromMarkdown; | ||
} | ||
|
||
return titleFromMarkdown.replace(/^#( |)/, ''); | ||
}; | ||
|
||
export default getTitleFromMarkdown; |
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,23 @@ | ||
import get from 'lodash/get'; | ||
import getTitleFromMarkdown from './get-title-from-markdown'; | ||
|
||
const removeTitleFromMarkdown = (markdown) => { | ||
const titleFromMarkdown = getTitleFromMarkdown(markdown); | ||
|
||
if (!titleFromMarkdown) { | ||
return markdown; | ||
} | ||
|
||
const content = get(markdown, '[0].content'); | ||
|
||
// Need to mutate the value passed in as it has specific | ||
// context used to render component examples | ||
markdown.splice(0, 1, { | ||
...markdown[0], | ||
content: content.replace(titleFromMarkdown, '').trimLeft(), | ||
}); | ||
|
||
return markdown; | ||
}; | ||
|
||
export default removeTitleFromMarkdown; |
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