/jekyll_slugify

An extension to Ruby's String class that adds a Jekyll-style slugify method.

Primary LanguageRubyMIT LicenseMIT

jekyll_slugify

Gem License Contributor Covenant

Travis (.org) Code Climate maintainability Code Climate coverage Libraries.io dependency status for GitHub repo

An extension to Ruby's String class that adds Jekyll-style #slugify method.

Installing

  1. Add jekyll_slugify to dependencies:
    1. Gemfile: gem 'jekyll_slugify', '~> VERSION'; or
    2. gemspec file: spec.add_dependency 'jekyll_slugify', '~> VERSION';
  2. Run bundle install to fetch the gem from RubyGems;
  3. Require the gem on your code: require 'jekyll_slugify'
  4. Apply the #slugify method on a string:
@foo = 'Hello Worlds!'
puts @foo.slugify
    => hello-worlds

Do note, however, that the slugify method will not work on ideograms - an ideogram-only word will actually raise an error!

puts 'Ærøskøbing'.slugify # Works
    => aeroskobing

puts '指事字'.slugify # Raises a Runtime error
    => Empty `slug` generated for given String (RuntimeError)

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request 🎉

Please, also read our Contributing Guidelines.

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

History & Versioning

See the Change Log for further history.

This project uses SemVer for versioning. For the versions available, see the tags on this repository.

Legal Stuff

MIT License

This project is available under the MIT License.

The code on this project is adapted from Jekyll's Utils#slugify method, available under the same MIT License.