Unicode-aware URL slug generator with transliteration and collision handling
dart pub add philiprehberger_slugUnicode-aware URL slug generator with transliteration and collision handling
Add to your pubspec.yaml:
dependencies:
philiprehberger_slug: ^0.1.1
Then run:
dart pub get
import 'package:philiprehberger_slug/slug.dart';
final slug = Slug.generate('Hello World!');
// => 'hello-world'
Slug.generate('Ünïcödé Tëxt');
// => 'unicode-text'
Slug.generate('Café résumé');
// => 'cafe-resume'
Slug.generate('Hello World', separator: '_');
// => 'hello_world'
Slug.generate('A very long title that should be truncated', maxLength: 20);
// => 'a-very-long-title'
Slug.withSuffix('hello-world', 2);
// => 'hello-world-2'
| 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 |
dart pub get
dart analyze --fatal-infos
dart test
If you find this project useful: