philiprehberger_slug
Unicode-aware URL slug generator with transliteration and collision handling
Requirements
- Dart >= 3.6
Installation
Add to your pubspec.yaml:
dependencies:
philiprehberger_slug: ^0.1.0
Then run:
dart pub get
Usage
import 'package:philiprehberger_slug/slug.dart';
final slug = Slug.generate('Hello World!');
// => 'hello-world'
Unicode Transliteration
Slug.generate('Ünïcödé Tëxt');
// => 'unicode-text'
Slug.generate('Café résumé');
// => 'cafe-resume'
Custom Separator
Slug.generate('Hello World', separator: '_');
// => 'hello_world'
Max Length
Slug.generate('A very long title that should be truncated', maxLength: 20);
// => 'a-very-long-title'
Collision Handling
Slug.withSuffix('hello-world', 2);
// => 'hello-world-2'
API
| Method | Description |
|---|---|
Slug.generate(input, {separator, maxLength}) |
Generate a URL-safe slug from any string |
Slug.withSuffix(slug, suffix, {separator}) |
Append a numeric suffix for collision avoidance |
Development
dart pub get
dart analyze --fatal-infos
dart test
Support
If you find this project useful:
License
Libraries
- philiprehberger_slug
- Unicode-aware URL slug generator with transliteration and collision handling.
- slug