-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
6 changed files
with
35 additions
and
9 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,12 @@ | ||
export const getPathBlog = (slug?: string) => `/blog${slug ? `/${slug}` : ''}`; | ||
export const getPathBlog = (slug?: string) => `/blog${slug ? `/${slug}` : ''}`; | ||
|
||
export function slugify(str: any) { | ||
return String(str) | ||
.normalize('NFKD') // split accented characters into their base characters and diacritical marks | ||
.replace(/[\u0300-\u036f]/g, '') // remove all the accents, which happen to be all in the \u03xx UNICODE block. | ||
.trim() // trim leading or trailing whitespace | ||
.toLowerCase() // convert to lowercase | ||
.replace(/[^a-z0-9 -]/g, '') // remove non-alphanumeric characters | ||
.replace(/\s+/g, '-') // replace spaces with hyphens | ||
.replace(/-+/g, '-'); // remove consecutive hyphens | ||
} |
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