@feelinglovelynow/slug
v1.1.1
Published
Helper function to create a slug (does not require Svelte) and a Svelte component to generate slugs in the browser (requires Svelte)
Downloads
4
Maintainers
Readme
🕉 @feelinglovelynow/slug
💎 Install
pnpm add @feelinglovelynow/slug
🤓 Unit Tests
🙏 Description
- Helper function to create a slug (does not require Svelte) and a Svelte component to generate slugs in the browser (requires Svelte)
- Converts
Hello World 123!
tohello-world-123
💚 How it works
- Lowercase all letters
- Remove anything that is not a space, a-z, or 0-9
- Remove space at end and beginning
- IF two or more spaces found next to each other, convert to one space
- Convert spaces to dashes
💛 Example: Slug function
import { slug } from '@feelinglovelynow/slug'
// foo-bar-hello-world-123
const response = slug(' ,.:foo ?!½)(@#$%^&* ;\'"{}[]|/`~bar <>_=+&¢£¥hello €© world® 123™·’\\ ')
🧡 Example: Slug component
<script lang="ts">
import { Slug } from '@feelinglovelynow/slug'
</script>
<Slug />
❤️ Add custom styling to svelte component
.fln__slug {
textarea {
}
&__generated {
}
}
🎁 All Our Packages
- @feelinglovelynow/datetime-local: NPM ⋅ Github
- @feelinglovelynow/dgraph: NPM ⋅ Github
- @feelinglovelynow/env-write: NPM ⋅ Github
- @feelinglovelynow/get-form-entries: NPM ⋅ Github
- @feelinglovelynow/get-relative-time: NPM ⋅ Github
- @feelinglovelynow/global-style: NPM ⋅ Github
- @feelinglovelynow/jwt: NPM ⋅ Github
- @feelinglovelynow/loop-backwards: NPM ⋅ Github
- @feelinglovelynow/slug: NPM ⋅ Github
- @feelinglovelynow/svelte-catch: NPM ⋅ Github
- @feelinglovelynow/svelte-kv: NPM ⋅ Github
- @feelinglovelynow/svelte-loading-anchor: NPM ⋅ Github
- @feelinglovelynow/svelte-modal: NPM ⋅ Github
- @feelinglovelynow/svelte-turnstile: NPM ⋅ Github
- @feelinglovelynow/toast: NPM ⋅ Github