slugify

package module
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2020 License: MIT Imports: 4 Imported by: 0

README

go-slugify

Build Status Go Report Card GoDoc

URL Slug.

Installation

go get -u github.com/shopsmart/go-slugify

Install CLI tool:

go get -u github.com/shopsmart/go-slugify/slugify
$ slugify "Brad's Deals & abc"
brads-deals-abc

Documentation

API documentation can be found here: https://godoc.org/github.com/shopsmart/go-slugify

Usage

package main

import (
  "fmt"
  "github.com/shopsmart/go-slugify"
)

func main() {
  s := "Brad's Deals & abc"
  fmt.Println(slugify.Slugify(s))
  // Output: brads-deals-abc
}

Documentation

Overview

Package slugify implements URL Slug Pattern

s := "Brad's Deals & Shopsmart"
fmt.Println(slugify.Slugify(s))
// Output: brads-deals-shopsmart

Index

Examples

Constants

This section is empty.

Variables

View Source
var ReInValidChar = regexp.MustCompile(fmt.Sprint("[^a-zA-Z0-9]+"))

ReInValidChar match invalid slug string

View Source
var Separator = "-"

Separator separator between words

View Source
var StripChar = regexp.MustCompile(fmt.Sprint("['\"`]", ""))

StripChar removes invalid slug characters

Functions

func Slugify

func Slugify(s string) string

Slugify implements make a pretty slug from the given text. e.g. Slugify("kožušček hello world") => "kozuscek-hello-world"

Example
package main

import (
	"fmt"

	"github.com/shopsmart/go-slugify"
)

func main() {
	s := "Nín hǎo. Wǒ shì zhōng guó rén This is a test, Brad's Deals ---"
	fmt.Println(slugify.Slugify(s))
}
Output:
nin-hao-wo-shi-zhong-guo-ren-this-is-a-test-brads-deals

func Version

func Version() string

Version return version

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL