shopify-slugify
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Shopify Slugify

npm version License: MIT

Overview

Shopify Slugify is a simple npm package that provides a function for creating slugs from strings. It replaces special characters, removes spaces, and converts text to a URL-friendly format.

Installation

npm install shopify-slugify

Usage in JavaScript/Node.js

Once the package is installed, you can use it in your JavaScript/Node.js code. Import the slugify function and call it with a string to generate a slug:

import { slugify } from "shopify-slugify";

const inputString = "This is a Sample String!";
const slug = slugify(inputString);
console.log(slug);
// Output: this-is-a-sample-string

The slugify function takes a string as an argument and returns a slugified version of the input string. It performs the following transformations:

  • Converts the string to lowercase.
  • Replaces spaces with hyphens.
  • Replaces special characters with their corresponding ASCII equivalents.
  • Removes non-word characters (except for º and +).
  • Replaces multiple hyphens with a single hyphen.
  • Trims hyphens from the start and end of the resulting string.

Package Sidebar

Install

npm i shopify-slugify

Weekly Downloads

5

Version

1.0.4

License

MIT

Unpacked Size

8.3 kB

Total Files

8

Last publish

Collaborators

  • loxt