Skip to content

polischuk/SlugGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is SlugGenerator?

SlugGenerator it's simple Slug and clean URL generator. Supports multiple languages such as: Cyrillic, Latin, Chinese and other languages encodings

Where can I get it?

Install from the package manager console:

PM> Install-Package SlugGenerator

Slug generation

Simple usage

  using SlugGenerator;
  
  "my test text".GenerateSlug(); // return my-test-text

Using Custom space separator

  using SlugGenerator;
  
  "my test text".GenerateSlug("_"); // set "_" as separator and return "my_test_text" string

Multilanguage feature

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-

Generate Unique slug

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

Releases

No releases published

Packages

No packages published

Languages