Skip to content

Generate slug from string, includes custom and language-specific transliterations

License

Notifications You must be signed in to change notification settings

einar-hjortdal/slugify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

783575f · Dec 7, 2024

History

24 Commits
Jun 14, 2023
Jun 13, 2023
Jun 13, 2023
Jun 14, 2023
Sep 25, 2024
Sep 15, 2024
Dec 7, 2024
Dec 7, 2024
Dec 7, 2024
Dec 7, 2024
Dec 7, 2024
Dec 7, 2024
Dec 7, 2024
Dec 7, 2024
Dec 7, 2024
Dec 7, 2024
Dec 7, 2024

Repository files navigation

slugify

Generate slug from string

Features

  • language-specific transliteration toggle
  • custom replacement map support
  • truncate at maximum character length
  • truncate at the end of a word before given maximum character length
  • transform to lowercase toggle

Usage

Install with v install einar-hjortdal.slugify

import einar_hjortdal.slugify

slugifier := slugify.default()
slug := slugifier.make('Slugs are NOT snails') // slugs-are-not-snails

Please refer to slugify_test.v for more information.

Notes

make and make_lang return a string that:

  • contains exclusively word characters (\w) and hyphens (-).
  • does not start nor end with hyphens (-) or underscores (_).
  • may be empty: if the given string contains exclusively non-word characters and those characters are not contained in the substitutions.v file.

Pull requests are welcome to add support for more languages. To add subsitutions or a whole new language, please look at the substitutions.v file and at the CONTRIBUTING.md file.

About

Generate slug from string, includes custom and language-specific transliterations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages