slug/README.md

52 lines
1.4 KiB
Markdown
Raw Normal View History

2013-03-13 15:14:21 +01:00
slug
====
2013-03-13 15:17:44 +01:00
Package `slug` generate slug from unicode string, URL-friendly slugify with
2013-03-13 15:14:21 +01:00
multiple languages support.
2014-04-04 22:00:16 +02:00
[![GoDoc](https://godoc.org/github.com/gosimple/slug?status.png)](https://godoc.org/github.com/gosimple/slug)
[![Build Status](https://drone.io/github.com/gosimple/slug/status.png)](https://drone.io/github.com/gosimple/slug/latest)
2013-03-13 15:14:21 +01:00
2015-03-04 12:32:22 +01:00
[Documentation online](http://godoc.org/github.com/dalu/slug)
2014-04-07 22:43:26 +02:00
2013-03-13 15:14:21 +01:00
## Example
package main
2013-05-10 15:05:15 +02:00
2013-03-13 15:14:21 +01:00
import(
2014-04-04 22:00:16 +02:00
"github.com/gosimple/slug"
2013-03-13 15:14:21 +01:00
"fmt"
)
2013-05-10 15:05:15 +02:00
func main () {
text := slug.Make("Hellö Wörld хелло ворлд")
fmt.Println(text) // Will print hello-world-khello-vorld
someText := slug.Make("影師")
fmt.Println(someText) // Will print: ying-shi
enText := slug.MakeLang("This & that", "en")
fmt.Println(enText) // Will print 'this-and-that'
deText := slug.MakeLang("Diese & Dass", "de")
fmt.Println(deText) // Will print 'diese-und-dass'
2013-05-10 17:51:12 +02:00
slug.CustomSub = map[string]string{
"water": "sand",
}
textSub := slug.Make("water is hot")
fmt.Println(textSub) // Will print 'sand-is-hot'
2013-05-10 15:05:15 +02:00
}
2013-03-13 15:14:21 +01:00
## Installation
2015-03-04 12:30:14 +01:00
go get -u github.com/dalu/slug
2013-03-13 15:14:21 +01:00
## License
2013-05-10 15:05:15 +02:00
The source files are distributed under the
2013-03-13 15:14:21 +01:00
[Mozilla Public License, version 2.0](http://mozilla.org/MPL/2.0/),
2013-05-10 15:05:15 +02:00
unless otherwise noted.
2013-03-13 15:14:21 +01:00
Please read the [FAQ](http://www.mozilla.org/MPL/2.0/FAQ.html)
if you have further questions regarding the license.