justintime50/slugify

This package is abandoned and no longer maintained. No replacement package was suggested.

Slugify a string. Perfect for URLs!

Installs: 196

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Language:JavaScript

Type:project

v1.3.0 2020-07-16 06:19 UTC

This package is auto-updated.

Last update: 2020-09-12 21:25:59 UTC


README

Slugify a string. Perfect for URLs!

Build Status Coverage Status NPM Licence

Showcase

Install

npm i justintime50-slugify

NOTE: This project requires jQuery for an HTML implementation.

Usage

Website

See Slugify in action here: https://justintime50.github.io/slugify.

Javascript Example

Pass in text and slug the result in console.

const slugify = require("justintime50-slugify");

console.log(slugify("Here is my FIRST -- Slug!", { lowercase: true }));
//=> 'here-is-my-first-slug'

Options

  • lowercase: true/false (default: false)

HTML Form Example

Transform a blog title into a slug to easily create our article URL.

<label for="title">Title</label>
<input type="text" class="title" name="title">

<label for="slug">Slug (URL)</label>
<input type="text" class="slug" name="slug">

<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="path/to/slugify/index.js"></script>

<script>
    // We slugify whatever is typed into the "title" field into the "slug" field in real time.
    slugifyField(".title", ".slug");
</script>

Development

# Lint the project
npx eslint index.js

# Test the project
npm run test

Attributions

Based on snippets from mathewbyrne and sindresorhus.