Skip to content

Commit

Permalink
fix(website): revise anchor links (pmndrs#775)
Browse files Browse the repository at this point in the history
* fix(website): revise anchor links

* fix(website): revise anchor links
  • Loading branch information
sandren authored Oct 13, 2021
1 parent 582646a commit b68c6d0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions website/src/components/mdx.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ export const A = ({ href, children, ...rest }) => {
)
}

const getAnchor = (text) => {
return typeof text === 'string'
? text.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase()
const getAnchor = (value) => {
return typeof value === 'string'
? value
.replace(/ /g, '-')
.replace(/([a-z])([A-Z])/g, '$1-$2')
.toLowerCase()
: ''
}

0 comments on commit b68c6d0

Please sign in to comment.