-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(discorddocs): handle more edge cases
* non-exact matching anchors and section headings * true title case comparison (words < 3 lowercased) * remove colons from heading anchors * remove example comment that's no longer relevant * try mdx if md is 404 * loosely compare anchors resolves #216
- Loading branch information
1 parent
4d007af
commit 30e04a8
Showing
2 changed files
with
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Transform provided text to Titlecase | ||
* (words shorter than 3 characters are lowercased) | ||
* | ||
* @param text - The text to fransform | ||
* @returns Transformed text | ||
*/ | ||
export function toTitlecase(text: string) { | ||
return text | ||
.trim() | ||
.split(' ') | ||
.map((word) => { | ||
if (word.length < 3) { | ||
return word.toLowerCase(); | ||
} | ||
|
||
return word[0]!.toUpperCase() + word.slice(1); | ||
}) | ||
.join(' '); | ||
} |