1
0
Fork 0
mirror of https://github.com/avelino/awesome-go.git synced 2024-11-13 11:14:37 -05:00
go/pkg/slug/generator.go

15 lines
326 B
Go
Raw Normal View History

2022-08-30 17:52:53 -04:00
package slug
import (
"strings"
"github.com/avelino/slugify"
)
2022-08-31 03:33:41 -04:00
// Generate slugs similar to GitHub's slugs on markdown parsing
2022-08-30 17:52:53 -04:00
func Generate(text string) string {
2023-02-14 15:26:37 -05:00
// FIXME: this is should be like regexp.Replace(`[^-a-zA-Z\d]+`, ``)
2022-08-30 17:52:53 -04:00
s := strings.ReplaceAll(text, "/", "")
return slugify.Slugify(strings.TrimSpace(s))
}