Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/taishikato/slug-generator
Slug generator for blog posts or any other contents :pencil:
https://github.com/taishikato/slug-generator
npm npm-module npm-package slug slug-generator typescript
Last synced: 26 days ago
JSON representation
Slug generator for blog posts or any other contents :pencil:
- Host: GitHub
- URL: https://github.com/taishikato/slug-generator
- Owner: taishikato
- License: mit
- Created: 2020-03-22T05:31:38.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-27T14:40:30.000Z (over 2 years ago)
- Last Synced: 2024-09-16T14:40:20.295Z (about 2 months ago)
- Topics: npm, npm-module, npm-package, slug, slug-generator, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@taishikato/slug-generator
- Size: 17.6 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @taishikato/slug-generator
![npm (scoped)](https://img.shields.io/npm/v/@taishikato/slug-generator)
![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@taishikato/slug-generator?label=minified%20size)## Install
With npm
```shell
$ npm i @taishikato/slug-generator
```
With yarn
```shell
$ yarn add @taishikato/slug-generator
```## Usage
```javascript
import generateSlug from '@taishikato/slug-generator';generateSlug('My first blog post title (March 21)');
// → my-first-blog-post-title-march-21/**
* When you pass true as a second argument, the slug will have a random strings at the end
* This is useful when some items(i.e. blog posts) can have the same title, which means those will have the same slug
* and you want a unique slug for each item.
*/
generateSlug('My first blog post title (March 21)', true);
// → my-first-blog-post-title-march-21-1cc703f7
```