Skip to content

Commit

Permalink
fix anchor link generator for camel cased acronyms
Browse files Browse the repository at this point in the history
  • Loading branch information
0div committed Nov 27, 2024
1 parent 99bba4c commit 4161d41
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/web/prebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ function toAnchorLink(title) {
// Remove special characters except dashes and spaces
title = title.replace(/[^a-zA-Z0-9\- ]/g, '')
// Add dashes between words for camelCase
title = title.replace(/([a-z])([A-Z])/g, '$1-$2')
title = title
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
.replace(/([a-z])([A-Z])/g, '$1-$2')
return '#' + title.toLowerCase().replace(/ /g, '-')
}

Expand Down

0 comments on commit 4161d41

Please sign in to comment.