package slug
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9ded4745abd9b93121307b026b41880f641e4ecc812a798a98bda88b4bae1f99
md5=4a3663a216f8a2696d6897f99c98b80b
Description
A URL slug is the part of a URL or link that comes after the domain extension.
In websites the keyword used for your URL slug can be used to SEO optimize the URL by showing Google the structure of your site and the contents of the page in question.
Added to opam-repository:
README
ocaml-slug
Url safe slug generator for OCaml
This library turns title into URL-safe slug with support for non-latin characters.
This library uses algorithm and data from node-slugify
Installation
opam install slugIf you use esy
esy add @opam/slugUsage
- OCaml syntax:
Slug.slugify "my string";;
- : string = "my-string"
(* Custom separator *)
Slug.slugify ?sep: "_" "my string";;
- : string = "my_string"
(* Retain uppercase *)
Slug.slugify ?lowercase: false "My String";;
- : string = "My-String"
(* Use locale *)
let with_vi = Slug.(Charmap.mk_charmap [Slug_data.base; Slug_data.vi]);;
- : Charmap.t = <abstr>
Slug.slugify ?charmap: with_vi "Đ";;
- : string = "d"
Slug.slugify "Đ";;
- : string = "dj"
(* Custom characters map *)
let custom_map = Slug.(Charmap.mk_charmap [Slug_data.base; [ ("M", "z"); ("m", "z") ]]);;
val custom_map : Charmap.t = <abstr>
Slug.slugify ?charmap: custom_map "Mm";;
- : string = "zz"- ReasonML syntax
Slug.slugify("my string");
- : string = "my-string"
/* Custom separator */
Slug.slugify(~sep = "_", "my string");
- : string = "my_string"
/* Retain uppercase */
Slug.slugify(~lowercase = false, "My String");
- : string = "My-String"
/* Use locale */
let with_vi = Slug.(Charmap.mk_charmap([Slug_data.base, Slug_data.vi]));
let with_vi : Charmap.t = <abstr>
Slug.slugify(~charmap = with_vi, "Đ");
- : string = "d"
Slug.slugify("Đ");
- : string = "dj"
/* Custom characters map */
let custom_map = Slug.(Charmap.mk_charmap([Slug_data.base, [ ("M", "z"), ("m", "z") ]]));;
let custom_map : Charmap.t = <abstr>
Slug.slugify(~charmap = custom_map, "Mm");
- : string = "zz"Notice
Please don't send PR to update data/*. They are auto-generated from upstream library.
Please send PRs about new locales to node-slugify.
If you really need it, you can use a custom_map instead.
License
MIT. Data are downloaded from node-slugify
Optional Dependencies
None
Used by (2)
-
camyll
>= "0.4.0" -
starred_ml
>= "0.0.6" & < "0.0.8"
Conflicts
None
Build status
Results of building slug with each compiler on check.ci.ocaml.org, run of against opam-repository 78c202b. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 1.0.1 (this version) | good | good | good | good | good |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure