Sluggy 2.0.1

.NET Standard 2.0
There is a newer version of this package available.
See the version list below for details.
Install-Package Sluggy -Version 2.0.1
dotnet add package Sluggy --version 2.0.1
<PackageReference Include="Sluggy" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sluggy --version 2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Sluggy, 2.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Sluggy as a Cake Addin
#addin nuget:?package=Sluggy&version=2.0.1

// Install Sluggy as a Cake Tool
#tool nuget:?package=Sluggy&version=2.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Sluggy | SluggyUnidecode

sluggy sluggyUnidecode


Build Status codecov

CodeFactor Codacy Badge


Sluggy

NuGet

dotnet add package Sluggy --version 2.0.1

Sluggy is a configuration based class library designed to create friendly URL's.


Sluggy Unidecode

NuGet

dotnet add package SluggyUnidecode --version 1.1.3

SluggyUnidecode is simple and powerful. Extends the Sluggy package by using the Unidecode.NET library for normalization.


QuickStart with Sluggy

There are 4 ways to use ToSlug()

The default is new CompositeStrategy(new ToLowerInvariantStrategy(), new NormalizationStrategy())
Default separator is "-"

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"

You can redefine the separator

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"

You can redefine the default composite strategy by passing as a param

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"

And lastly you can redefine the default separator and the composite strategy

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"

QuickStart with SluggyUnidecode

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"

Contributing

Any contribution is allowed, submit a issue or pull request to start contributing your ideias or problems you encounter.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Acknowledgments

  • To Sérgio Freitas[sj-freitas] for the idea, challenge, guidance and the amazing logo designs.
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Sluggy:

Package Downloads
SluggyUnidecode

SluggyUnidecode is a powerful slugifier designed to create friendly URL's. Simple and powerful. Extends the Sluggy package by using the Unidecode.Net library for normalization.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.1 10,056 5/26/2020
2.0.2 4,906 6/27/2019
2.0.1 960 12/27/2018
2.0.0 641 12/13/2018

# Changed the casing strategy to be configurable, default is toLowerInvariant.
# Added missing tests for strategies.
# Minor tweaks and cleanup to style.
# Updated documentation.
# Updated Icon.