TS-Scribe - v1.2.0
    Preparing search index...

    Function slugify

    • Converts a string into a URL-friendly slug by removing accents, replacing spaces and special characters, and optionally converting to lowercase. Perfect for generating SEO-friendly URLs, filenames, and identifiers.

      Parameters

      • input: string

        The input string to slugify.

      • Optionaloptions: SlugifyOptions = {}

        Options to customize the slugification process.

      Returns string

      The slugified version of the input string.

      // Basic usage (strict mode, lowercase by default)
      slugify("Hello World!")
      // Returns "hello-world"
      // With custom replacement
      slugify("Hello World! How are you?", { replacement: "-" })
      // Returns "hello-world-how-are-you"
      // Remove accents and special characters
      slugify("Café Münchën")
      // Returns "cafe-munchen"
      // Custom replacement character
      slugify("TypeScript is Great", { replacement: "_" })
      // Returns "typescript_is_great"
      // Remove specific characters with custom regex
      slugify("Product #42 (New!)", { remove: /[#()!]/g })
      // Returns "product-42-new"
      // Non-strict mode (only replaces spaces)
      slugify("Hello@World.com", { strict: false })
      // Returns "hello@world.com"