Skip to content
🐌 Minimalistic slug generator library
F# Other
  1. F# 99.1%
  2. Other 0.9%
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets
samples
src/FSlugify
tests/FSlugify
.editorconfig
.gitattributes
.gitignore
.travis.yml
LICENSE.md
README.md
appveyor.yml
build.cmd
build.sh
fslugify.sln

README.md

FSlugify

Build status Build Status NuGet

Simple and minimalistic slug generator library written entirely in F#.

It's easy to use and has no extra dependencies.

Add package

If you want to add this package to your project, execute the following command:

dotnet add package FSlugify --version 1.0.0

Build on your machine

If you want to build this library on your machine, execute the following commands:

git clone https://github.com/galassie/fslugify.git
cd fslugify
dotnet build

If you want to run the tests, execute the following command:

dotnet test

Usage

You can see the some examples in the folder "samples" (both in C# and F#).

Here how it looks a simple F# program that uses this library:

open FSlugify.SlugGenerator

[<EntryPoint>]
let main argv =
    printfn "This is a series of examples on how to use the SlugGenerator!\n"

    slugify DefaultSlugGeneratorOptions "Déjà Vu!"
    |> printfn "Slug generated from \"Déjà Vu!\" with default options: \"%s\"\n"

    slugify { DefaultSlugGeneratorOptions with Separator = '#' } "Déjà Vu!"
    |> printfn "Slug generated from \"Déjà Vu!\" with custom separator: \"%s\"\n"
    
    slugify { DefaultSlugGeneratorOptions with Lowercase = false } "Déjà Vu!"
    |> printfn "Slug generated from \"Déjà Vu!\" without lowercase: \"%s\"\n"
    
    let customMap = [("|", " or "); ("🤡", " clown ")]
    slugify { DefaultSlugGeneratorOptions with CustomMap = customMap } "Test | 🤡"
    |> printfn "Slug generated from \"Test | 🤡\" with custom map: \"%s\"\n"
    0

This program will output the following text:

This is a series of examples on how to use the SlugGenerator!

Slug generated from "Déjà Vu!" with default options: "deja_vu"

Slug generated from "Déjà Vu!" with custom separator: "deja#vu"

Slug generated from "Déjà Vu!" without lowercase: "Deja_Vu"

Slug generated from "Test | 🤡" with custom map: "test_or_clown"

FSlugify.Adapter

Although the library is usable as it is in a C# project (as it shown in the C# sample), for a better usability (both in syntax and usability) it's preferred to use the library FSlugify.Adapter.

Contributing

Code contributions are more than welcome! 😻

Please commit any pull requests against the master branch.
If you find any issue, please report it!

License

This project is licensed under The MIT License (MIT).

Author: Enrico Galassi

You can’t perform that action at this time.