Skip to content
IvanbyonePublic

About

Fast, low-alloc Go slug generator with an elegant Fluent API.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

slugigo

Fast, low-alloc Go slug generator with an elegant Fluent API.

GH Release Slugigo CI Status Slugigo License Go documentation

Quick Start

Installation

go get -u github.com/ivanbyone/slugigo

Usage example

package main

import (
    "fmt"
    "github.com/ivanbyone/slugigo"
)

func main() {
    // Basic usage (ASCII, default compliance RFC-3986)
    slug := slugigo.Slug("Hello, Slugigo!").Build()
    fmt.Println(slug)
    // Output: hello-slugigo

    // Advanced custom configuration
    custom := slugigo.Slug("Hello, Fluent Slugigo").
        NoLowercase().
        MaxLength(12).
        Separator("_").
        SaveLeadingAndTrailingDash().
        Build()
    fmt.Println(custom)
    // Output: 
}

Concept

Package slugigo provides functionality for generating URL-friendly slugs due to standard RFC-3986. So, default output complies with the following rules:

  • Acceptable ASCII characters:
    • only lowercase letters: a-z
    • numbers: 0-9
    • dash: -
    • underscore: _
    • dot: .
  • Default separator: -
  • Unacceptable leading and trailing dashes.

You can set custom configuration for use due to your needs. See more in docs.

Roadmap

v0.2.0

  • Improve library code style
  • Add Go benchmarks
  • Compile comprehensive documentation
  • Key feature: custom replacements with Fluent style

Stable release

  • Major: Multiple languages transliteration support
  • Minor:
    • support Prefix() & Suffix()
    • generating dates for slug (UNIX, Datetime)
    • emoji replacements

License

This project is licensed under the terms of the MIT license. See LICENSE file for details.

About

Fast, low-alloc Go slug generator with an elegant Fluent API.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages