dotnet add package Sluggy --version 3.0.1
Sluggy is a configuration based class library designed to create friendly URL's.
Check release notes for more info on the latest changes.
dotnet add package SluggyUnidecode --version 2.0.0
SluggyUnidecode is simple and powerful. Extends the Sluggy package by using the Unidecode.NET library for normalization.
Check release notes for more info on the latest changes.
NonAlphaNumericStrategy()
ToLowerInvariantStrategy()
NormalizationStrategy()
Easiest way:
using Sluggy;
"EU GOSTO DE TÁRTE".ToSlug();
// Output: "eu-gosto-de-tarte"
"Eu NãO GoStO de PãO Da Avó".ToSlug();
// Output: "eu-nao-gosto-de-pao-da-avo"
using Sluggy;
// Defining the separator
var separator = "/";
"EU GOSTO DE TÁRTE".ToSlug(separator);
// Output: "eu/gosto/de/tarte"
"Eu NãO GoStO de PãO Da Avó".ToSlug(separator);
// Output: "eu/nao/gosto/de/pao/da/avo"
using Sluggy;
// Defining the composite strategy
var defaultStrategy = new CompositeStrategy(
new ToLowerInvariantStrategy(),
new NormalizationStrategy());
"EU GOSTO DE TÁRTE".ToSlug(defaultStrategy);
// Output: "eu-gosto-de-tarte"
"Eu NãO GoStO de PãO Da Avó".ToSlug(defaultStrategy);
// Output: "eu-nao-gosto-de-pao-da-avo"
// Redefine the composite strategy
var anotherStrategy = new CompositeStrategy(
new ToLowerInvariantStrategy(),
new NormalizationStrategy(),
new RemoveEveryVowelStrategy());
"GOSTO DE TÁRTE".ToSlug(anotherStrategy);
// Output: "gst-d-trt"
using Sluggy;
// Defining the separator
var separator = "/";
// Defining the composite strategy
var normalizationWithUpperCaseStrategy = new CompositeStrategy(
new ToUpperCaseStrategy(),
new NormalizationStrategy());
"EU GOSTO DE TÁRTE".ToSlug(separator, normalizationWithUpperCaseStrategy);
// Output: "EU/GOSTO/DE/TARTE"
// Redefine the composite strategy
var anotherStrategy = new CompositeStrategy(
new ToLowerInvariantStrategy(),
new NormalizationStrategy(),
new RemoveEveryVowelStrategy());
"GOSTO DE TÁRTE".ToSlug(separator, anotherStrategy);
// Output: "gst/d/trt"
SluggyUnidecode is simple and uses a powerful normalizer to ASCII characters.
using SluggyUnidecode;
"Мне нравится татарин".ToSlug();
// Output: "mne-nravitsya-tatarin"
"ア α a A".ToSlug();
// Output: "a-a-a-a";
// Even more powerful
"ch\u00e2teau Vi\u00f1edos".ToSlug();
// Output: "chateau-vinedos"
Any contribution is allowed, submit a issue or pull request to start contributing your ideias or problems you encounter.
- Ruben Mateus - rubenmateus
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details.
- To Sérgio Freitas[sj-freitas] for the idea, challenge, guidance and the amazing logo designs.