module Marten::Core::Sluggable

Overview

The Sluggable module provides functionality for generating URL-friendly slugs from strings.

Direct including types

Defined in:

marten/core/sluggable.cr

Instance Method Summary

Instance Method Detail

def generate_slug(value, max_size) #

Generates a slug from the given value, ensuring the resulting slug does not exceed the specified max_size.

The slug is created by:

  1. Removing non-alphanumeric characters (except for Unicode letters, numbers, symbols, whitespace, and hyphens).
  2. Converting the string to lowercase.
  3. Replacing sequences of whitespace and hyphens with a single hyphen.
  4. Stripping trailing hyphens and underscores from the slug.
  5. Truncating the slug to the specified max_size.

[View source]