{"id":21988007,"url":"https://github.com/jmrashed/go-slugger","last_synced_at":"2025-03-23T02:41:37.486Z","repository":{"id":264124919,"uuid":"892443051","full_name":"jmrashed/go-slugger","owner":"jmrashed","description":"go-slugger is a Go package for generating slugs from strings.","archived":false,"fork":false,"pushed_at":"2024-11-22T08:09:28.000Z","size":193,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-28T05:43:06.959Z","etag":null,"topics":["go","package","slugger"],"latest_commit_sha":null,"homepage":"","language":"Go","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/jmrashed.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-22T05:50:25.000Z","updated_at":"2024-11-22T08:09:31.000Z","dependencies_parsed_at":"2024-11-22T06:27:38.008Z","dependency_job_id":"97beffa5-08c8-42b4-be07-b316baacd5f6","html_url":"https://github.com/jmrashed/go-slugger","commit_stats":null,"previous_names":["jmrashed/go-slugger"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrashed%2Fgo-slugger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrashed%2Fgo-slugger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrashed%2Fgo-slugger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmrashed%2Fgo-slugger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmrashed","download_url":"https://codeload.github.com/jmrashed/go-slugger/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245048281,"owners_count":20552483,"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":["go","package","slugger"],"created_at":"2024-11-29T19:15:17.443Z","updated_at":"2025-03-23T02:41:37.443Z","avatar_url":"https://github.com/jmrashed.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"```bash\n   _____           _____  _                                  \n  / ____|         / ____|| |                                 \n | |  __   ___   | (___  | | _   _   __ _   __ _   ___  _ __ \n | | |_ | / _ \\   \\___ \\ | || | | | / _` | / _` | / _ \\| '__|\n | |__| || (_) |  ____) || || |_| || (_| || (_| ||  __/| |   \n  \\_____| \\___/  |_____/ |_| \\__,_| \\__, | \\__, | \\___||_|   \n                                     __/ |  __/ |            \n                                    |___/  |___/       \n\nGoSlugger version v1.0.1 2024-11-22\n```\n\n# go-slugger\n\n`go-slugger` is a Go package for generating slugs from strings. It supports multiple languages, custom delimiters, diacritic removal, and more. This package is useful for generating clean, SEO-friendly slugs for URLs, making it easy to integrate with your web applications, CMS, or any system that needs slug generation.\n\n[![Forks](https://img.shields.io/github/forks/jmrashed/go-slugger?style=social)](https://github.com/jmrashed/go-slugger/forks)\n[![Issues](https://img.shields.io/github/issues/jmrashed/go-slugger)](https://github.com/jmrashed/go-slugger/issues)\n[![Releases](https://img.shields.io/github/downloads/jmrashed/go-slugger/latest/total)](https://github.com/jmrashed/go-slugger/releases)\n![License](https://img.shields.io/github/license/jmrashed/go-slugger)\n\n## Features\n\n- **Multi-language Support**: Generates slugs for strings in multiple languages, converting accented characters (e.g., `é`, `ö`) to their nearest ASCII equivalents.\n- **Custom Delimiters**: Allows you to specify a custom delimiter (default is `-`) for separating words in the slug.\n- **Diacritic Removal**: Automatically removes diacritical marks (accents) from characters.\n- **Truncation**: Optionally truncate slugs to a specified length.\n- **Case Sensitivity**: Control over whether the generated slug is lowercase.\n\n## Installation\n\nTo install `go-slugger`, use the Go Modules feature to fetch the package:\n\n```bash\ngo get github.com/jmrashed/go-slugger\n```\n\n## Usage\n\n### Basic Usage\n\nTo start using `go-slugger`, import the package into your Go file and use the `GenerateSlug` function.\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/jmrashed/go-slugger\"\n)\n\nfunc main() {\n    input := \"Hello World! Welcome to Go.\"\n    slug := slugger.GenerateSlug(input)\n    fmt.Println(slug) // Output: hello-world-welcome-to-go\n}\n```\n\n### Custom Delimiters\n\nYou can specify a custom delimiter (default is `-`) to separate words in the slug.\n\n```go\nslug := slugger.GenerateSlug(\"Hello World!\", \"_\")\nfmt.Println(slug) // Output: hello_world\n```\n\n### Diacritic Removal\n\nThe package automatically removes diacritical marks (accents) for characters like `é`, `ö`, etc.\n\n```go\nslug := slugger.GenerateSlug(\"Café de Paris\")\nfmt.Println(slug) // Output: cafe-de-paris\n```\n\n### Case Sensitivity\n\nThe default behavior is to generate slugs in lowercase. If you want to preserve the original case, you can pass a `false` flag for the `lowercase` parameter.\n\n```go\nslug := slugger.GenerateSlug(\"Hello World!\", \"-\", false)\nfmt.Println(slug) // Output: Hello-World\n```\n\n### Truncating Slugs\n\nYou can specify the maximum length of the generated slug. If the length exceeds this, it will be truncated.\n\n```go\nslug := slugger.GenerateSlug(\"This is a very long title\", \"-\", true, 20)\nfmt.Println(slug) // Output: this-is-a-very-lo\n```\n\n## API Reference\n\n### `GenerateSlug(input string, delimiter string, lowercase bool, maxLength int) string`\n\n- `input` (string): The string to convert into a slug.\n- `delimiter` (string, optional): The delimiter used in the slug. Default is `-`.\n- `lowercase` (bool, optional): Whether to generate the slug in lowercase (default: `true`).\n- `maxLength` (int, optional): Maximum length of the slug. The slug will be truncated if it exceeds this length.\n\nReturns the generated slug as a string.\n\n## Example\n\n### Full Example\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/jmrashed/go-slugger\"\n)\n\nfunc main() {\n    input := \"München ist schön!\"\n    \n    // Generate slug with default settings\n    slug1 := slugger.GenerateSlug(input)\n    fmt.Println(slug1) // Output: muenchen-ist-schoen\n    \n    // Generate slug with custom delimiter and case preservation\n    slug2 := slugger.GenerateSlug(input, \"_\", false)\n    fmt.Println(slug2) // Output: Muenchen_ist_schoen\n    \n    // Generate slug with truncation and custom length\n    slug3 := slugger.GenerateSlug(input, \"-\", true, 15)\n    fmt.Println(slug3) // Output: muenchen-ist-s\n}\n```\n\n## Contribution\n\nWe welcome contributions to `go-slugger`! If you’d like to contribute, please follow the steps below:\n\n1. Fork the repository\n2. Clone your fork locally\n3. Create a new branch for your changes\n4. Make your changes and add tests\n5. Open a pull request to the `main` branch\n\nFor more details, refer to the [CONTRIBUTING.md](CONTRIBUTING.md) file.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Changelog\n\nFor a detailed list of changes, refer to the [CHANGELOG.md](CHANGELOG.md).\n\n## Support\n\nIf you have any questions or need support, feel free to open an issue in the [GitHub Issues](https://github.com/jmrashed/go-slugger/issues) section.\n\nFor more detailed documentation, visit the [documentation folder](docs/). ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmrashed%2Fgo-slugger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmrashed%2Fgo-slugger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmrashed%2Fgo-slugger/lists"}