slug

package
v0.0.0-...-932f57c Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 15 Imported by: 0

README

Slug

Slug provides an easy way to create a pretty URL for your model.

Usage

Use slug.Slug as your field type with the same name as the benefactor field, from which the slug's value should be dynamically derived, and prepended with WithSlug, for example:


type User struct {
  gorm.Model
  Name            string
  NameWithSlug    slug.Slug
}

License

Released under the MIT License.

Documentation

Index

Constants

View Source
const (
	I18nSlugKey i18n.ModuleKey = "I18nSlugKey"
)

Variables

View Source
var Messages_en_US = &Messages{
	Sync: "Auto sync from %s",
}
View Source
var Messages_zh_CN = &Messages{
	Sync: "从%s自动同步",
}

Functions

func SlugEditingComponentFunc

func SlugEditingComponentFunc(field *presets.FieldContext, ctx *web.EventContext) h.HTMLComponent

func SlugEditingSetterFunc

func SlugEditingSetterFunc(obj interface{}, field *presets.FieldContext, ctx *web.EventContext) (err error)

func Slugify

func Slugify(value string) string

Types

type Builder

type Builder struct{}

func New

func New() *Builder

func (*Builder) Install

func (sb *Builder) Install(b *presets.Builder) error

func (*Builder) ModelInstall

func (sb *Builder) ModelInstall(b *presets.Builder, mb *presets.ModelBuilder) error

type Messages

type Messages struct {
	Sync string
}

type Slug

type Slug string

Jump to

Keyboard shortcuts

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