SlugGenerator it's simple Slug and clean URL generator. Supports multiple languages such as: Cyrillic, Latin, Chinese and other languages encodings
Install from the package manager console:
PM> Install-Package SlugGenerator
using SlugGenerator;
"my test text".GenerateSlug(); // return my-test-text
using SlugGenerator;
"my test text".GenerateSlug("_"); // set "_" as separator and return "my_test_text" string
Slug generator transliteration all basic languages to english charters
using SlugGenerator;
// Russian language
"привет как дела".GenerateSlug(); // return privet-kak-dela
"你好你怎麼樣".GenerateSlug(); // return ni-hao-ni-zen-mo-yang-
This method help u Generate unique slug, if slug already exist on list, method generate slug with additional numbers or guid.
using SlugGenerator;
public class ConcreteSlug : ISlug
{
public string Slug { get; set; }
}
var slug = item.Text.GenerateUniqueSlug(items);
var itemsList = new List<ConcreteSlug>
{
new ConcreteSlug
{
Slug = "test"
},
new ConcreteSlug
{
Slug = "test2"
}
};
var slug = "test".GenerateUniqueSlug(itemsList); // return slug which is not in an itemsList