npm i justintime50-slugify
NOTE: This project requires jQuery for an HTML implementation.
See Slugify in action here: https://justintime50.github.io/slugify.
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)
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>
# Lint the project
npx eslint index.js
# Test the project
npm run test
Based on snippets from mathewbyrne and sindresorhus.