• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.gitignoreH A D22-Oct-201916

.travis.ymlH A D22-Oct-2019378

LICENSEH A D22-Oct-201916.3 KiB

README.mdH A D22-Oct-20191.6 KiB

doc.goH A D22-Oct-20191.2 KiB

go.modH A D22-Oct-2019116

go.sumH A D22-Oct-2019235

languages_substitution.goH A D22-Oct-20191.8 KiB

slug.goH A D22-Oct-20194.7 KiB

slug_test.goH A D22-Oct-201915.9 KiB

README.md

1slug
2====
3
4Package `slug` generate slug from unicode string, URL-friendly slugify with
5multiple languages support.
6
7[![GoDoc](https://godoc.org/github.com/gosimple/slug?status.png)](https://godoc.org/github.com/gosimple/slug)
8[![Build Status](https://travis-ci.com/gosimple/slug.svg?branch=master)](https://travis-ci.com/gosimple/slug)
9
10[Documentation online](http://godoc.org/github.com/gosimple/slug)
11
12## Example
13
14```go
15package main
16
17import (
18	"fmt"
19	"github.com/gosimple/slug"
20)
21
22func main() {
23	text := slug.Make("Hellö Wörld хелло ворлд")
24	fmt.Println(text) // Will print: "hello-world-khello-vorld"
25
26	someText := slug.Make("影師")
27	fmt.Println(someText) // Will print: "ying-shi"
28
29	enText := slug.MakeLang("This & that", "en")
30	fmt.Println(enText) // Will print: "this-and-that"
31
32	deText := slug.MakeLang("Diese & Dass", "de")
33	fmt.Println(deText) // Will print: "diese-und-dass"
34
35	slug.Lowercase = false // Keep uppercase characters
36	deUppercaseText := slug.MakeLang("Diese & Dass", "de")
37        fmt.Println(deUppercaseText) // Will print: "Diese-und-Dass"
38
39	slug.CustomSub = map[string]string{
40		"water": "sand",
41	}
42	textSub := slug.Make("water is hot")
43	fmt.Println(textSub) // Will print: "sand-is-hot"
44}
45
46```
47
48### Requests or bugs?
49<https://github.com/gosimple/slug/issues>
50
51## Installation
52```sh
53go get -u github.com/gosimple/slug
54```
55
56## License
57
58The source files are distributed under the
59[Mozilla Public License, version 2.0](http://mozilla.org/MPL/2.0/),
60unless otherwise noted.
61Please read the [FAQ](http://www.mozilla.org/MPL/2.0/FAQ.html)
62if you have further questions regarding the license.
63