philiprehberger_slug 0.1.1 copy "philiprehberger_slug: ^0.1.1" to clipboard
philiprehberger_slug: ^0.1.1 copied to clipboard

Unicode-aware URL slug generator with transliteration and collision handling

philiprehberger_slug #

Tests pub package Last updated

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:

Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License #

MIT

0
likes
160
points
--
downloads

Documentation

API reference

Publisher

verified publisherphiliprehberger.com

Unicode-aware URL slug generator with transliteration and collision handling

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

More

Packages that depend on philiprehberger_slug