awesome-go/pkg/slug/generator.go

14 lines
273 B
Go
Raw Normal View History

2022-08-30 21:52:53 +00:00
package slug
import (
"strings"
"github.com/avelino/slugify"
)
func Generate(text string) string {
// remove slashes to create slugs similar to GitHub's slugs on markdown parsing
s := strings.ReplaceAll(text, "/", "")
return slugify.Slugify(strings.TrimSpace(s))
}