slug

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureUnique

func EnsureUnique(ctx context.Context, baseSlug, contentType string, checker SlugChecker) (string, error)

EnsureUnique ensures the slug is unique by appending a numeric suffix if needed

func Generate

func Generate(input string) string

Generate creates a URL-safe slug from the input string It transliterates Cyrillic to Latin, converts to lowercase, and replaces spaces with hyphens

func MachineName

func MachineName(input, prefix string) string

MachineName - a machine name ([a-z][a-z0-9_]*) from input, a title: Generate's transliteration with underscores; one not starting with a letter gets prefix (and prefix alone stands for an empty one).

func Validate

func Validate(slug string) error

Validate checks if a slug is valid

Types

type SlugChecker

type SlugChecker interface {
	SlugExists(ctx context.Context, slug, contentType string) (bool, error)
}

SlugChecker is an interface for checking if a slug exists

Jump to

Keyboard shortcuts

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