-
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.
feat: support multiple naming-styles, default to slug
- Loading branch information
1 parent
9578ab8
commit ad3391c
Showing
7 changed files
with
52 additions
and
4 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
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
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 @@ | ||
package util | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/gosimple/slug" | ||
"github.com/rs/zerolog/log" | ||
) | ||
|
||
// Slugify transforms a string for generate better directory names | ||
func Slugify(input string, namingStyle string) string { | ||
if namingStyle == "lowercase" { | ||
return strings.ToLower(input) | ||
} else if namingStyle == "slug" || namingStyle == "" { | ||
s := slug.Make(input) | ||
return strings.ToLower(s) | ||
} else if namingStyle == "name" { | ||
return input | ||
} | ||
|
||
log.Fatal().Msg("Invalid naming-scheme, must be one of: lowercase, slug, name") | ||
return input | ||
} |