sidmal / slug

URL-friendly slugify with multiple languages support.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

slug

This is fork of slug package.

This is fork has had a few improvements from the original slug package such as:

  • Added new private constants to setting of default language and word separator of slug
  • Extended MakeLang function. Now you can set word separator of slug as parameter of function
  • Extended body of Make function for comply new descriptor of MakeLag function

Package slug generate slug from unicode string, URL-friendly slugify with multiple languages support.

Example

package main

import (
	"fmt"
	"github.com/sidmal/slug"
)

func main() {
	text := slug.Make("Hellö Wörld хелло ворлд")
	fmt.Println(text) // Will print: "hello_world_khello_vorld"

	enText := slug.MakeLang("This & that", "en", "*")
	fmt.Println(enText) // Will print: "this*and*that"

	slug.CustomSub = map[string]string{
		"water": "sand",
	}
	textSub := slug.Make("water is hot")
	fmt.Println(textSub) // Will print: "sand-is-hot"
}

How install

go get -u github.com/sidmal/slug

License

License to original package you can find by this link

About

URL-friendly slugify with multiple languages support.

License:Mozilla Public License 2.0


Languages

Language:Go 100.0%