✨ Add Slug Generator
This commit is contained in:
parent
921020d9fd
commit
1d235af876
8 changed files with 124 additions and 1 deletions
22
options.go
22
options.go
|
|
@ -1,6 +1,10 @@
|
|||
package nomino
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/gosimple/slug"
|
||||
)
|
||||
|
||||
// Option sets configuration parameters for Config.
|
||||
type Option func(c *Config)
|
||||
|
|
@ -13,6 +17,22 @@ func WithOriginal(o string) Option {
|
|||
}
|
||||
}
|
||||
|
||||
// WithOriginal sets the original filename as a slug.
|
||||
// This should not be used with the Slug Generator (as it would be redundant)
|
||||
func WithOriginalSlug(o string) Option {
|
||||
return func(c *Config) {
|
||||
c.original = slug.Make(o)
|
||||
}
|
||||
}
|
||||
|
||||
// WithOriginal sets the original filename as a slug, taking the language into account.
|
||||
// This should not be used with the Slug Generator (as it would be redundant)
|
||||
func WithOriginalSlugLang(o, lang string) Option {
|
||||
return func(c *Config) {
|
||||
c.original = slug.MakeLang(o, lang)
|
||||
}
|
||||
}
|
||||
|
||||
// WithPrefix sets a prefix for the generated name.
|
||||
func WithPrefix(p string) Option {
|
||||
return func(c *Config) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue