Add Slug Generator

This commit is contained in:
Dan Jones 2025-03-13 16:58:55 -05:00
commit 1d235af876
8 changed files with 124 additions and 1 deletions

View file

@ -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) {