{"id":13509391,"url":"https://github.com/h4cc/slugger","last_synced_at":"2025-04-04T10:09:14.035Z","repository":{"id":26370217,"uuid":"29819448","full_name":"h4cc/slugger","owner":"h4cc","description":"A Slugger for elixir.","archived":false,"fork":false,"pushed_at":"2021-10-04T13:14:51.000Z","size":62,"stargazers_count":160,"open_issues_count":6,"forks_count":28,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T09:09:11.208Z","etag":null,"topics":["elixir","elixir-lang","elixir-library","slug","slugbuilder","slugger","slugify","url","url-filters"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/h4cc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-25T15:51:25.000Z","updated_at":"2025-01-25T07:55:49.000Z","dependencies_parsed_at":"2022-08-28T12:50:12.994Z","dependency_job_id":null,"html_url":"https://github.com/h4cc/slugger","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h4cc%2Fslugger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h4cc%2Fslugger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h4cc%2Fslugger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h4cc%2Fslugger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/h4cc","download_url":"https://codeload.github.com/h4cc/slugger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247157283,"owners_count":20893220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","elixir-lang","elixir-library","slug","slugbuilder","slugger","slugify","url","url-filters"],"created_at":"2024-08-01T02:01:07.113Z","updated_at":"2025-04-04T10:09:14.003Z","avatar_url":"https://github.com/h4cc.png","language":"Elixir","readme":"Slugger\n===============\n[![Build Status](https://travis-ci.org/h4cc/slugger.svg?branch=master)](https://travis-ci.org/h4cc/slugger)\n\nThis package provides a library and a protocol to create [slugs](http://en.wikipedia.org/wiki/Semantic_URL#Slug) for given strings.\n\nBy default, a slug will be containing _only_ chars `A-Za-z0-9` and the default seperator `-`.\n\nWant to use this library with Ecto? Have a look at [sobolevn/ecto_autoslug_field](https://github.com/sobolevn/ecto_autoslug_field).\n\n## Installation\n\nAdd `slugger` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:slugger, \"~\u003e 0.3\"},\n  ]\nend\n```\n\n## Configuration\n\nThe following options can be set in your `config.exs` and will be used at __next compile__!\n\n```elixir\n# Char used as separator between words.\nconfig :slugger, separator_char: ?-\n\n# Path to the file containing replacements.\nconfig :slugger, replacement_file: \"lib/replacements.exs\"\n```\n\n## Library\n\nUsing the library is straightforward, check out a few examples:\n\n```elixir\niex(1)\u003e Slugger.slugify \" A b C \"\n\"A-b-C\"\n\niex(2)\u003e Slugger.slugify_downcase \" A b C \"\n\"a-b-c\"\n\niex(3)\u003e Slugger.slugify \"A cool title of a blog post\"\n\"A-cool-title-of-a-blog-post\"\n\niex(4)\u003e Slugger.slugify_downcase(\"Kluski Śląskie @ Jalapeño Bilingüe\")\n\"kluski-slaskie-at-jalapeno-bilinguee\"\n\niex(5)\u003e Slugger.slugify \"Wikipedia Style\", ?_\n\"Wikipedia_Style\"\n\niex(6)\u003e Slugger.truncate_slug \"A-to-long-slug-that-should-be-truncated\", 16\n\"A-to-long-slug\"\n```\n\n## Protocol\n\nNext to the library, a protocol is provided to ease creating slugs for own data structures.\nBy default, the protocol will try to run `Slugger.slugify(Kernel.to_string(your_data))`, so if `your_data` implements `String.Chars`, the returned string will be slugified.\nIf you want to provide your own way to create a slug, check out the following example:\n\n```elixir\niex(10)\u003e defmodule User do\n...(10)\u003e   defstruct name: \"Julius Beckmann\"\n...(10)\u003e end\n\niex(11)\u003e defimpl Slugify, for: User do   \n...(11)\u003e   def slugify(user), do: Slugger.slugify(user.name)\n...(11)\u003e end\n\niex(12)\u003e Slugify.slugify %User{}                          \n\"Julius-Beckmann\"\n```\n\n## Replacements\n\nSpecial chars like `äöüéáÁÉ` will be replaced by rules given in the file [lib/replacements.exs](lib/replacements.exs).\n\nCopy that file if you need have own replacement rules, change the config value and __recompile__.\n","funding_links":[],"categories":["Text and Numbers"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh4cc%2Fslugger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fh4cc%2Fslugger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh4cc%2Fslugger/lists"}