awesome-go/pkg/slug/generator.go

14 lines
256 B
Go
Raw Normal View History

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