turkce-slugify
v0.2.0
Published
Tiny zero-dependency slugify for Turkish text
Downloads
185
Readme
turkce-slugify
Tiny, zero-dependency slugify for Turkish text.
npm install turkce-slugifyconst slugify = require('turkce-slugify');
slugify('Çalışkan Öğrenci Şükrü'); // 'caliskan-ogrenci-sukru'
slugify("İstanbul'da güneşli gün!"); // 'istanbul-da-gunesli-gun'
slugify('Merhaba Dünya', { separator: '_' }); // 'merhaba_dunya'
slugify('Kedi & Köpek', { replacements: { '&': 've' } }); // 'kedi-ve-kopek'Why
Most slugify libraries get ı and İ wrong: ı has no Unicode decomposition, and
'İ'.toLowerCase() leaves a stray combining dot. This package handles both.
Options
| Option | Default | Description |
| -------------- | ---------- | -------------------------------------------------------- |
| separator | '-' | String placed between words. |
| lowercase | true | Lower-case the result. |
| maxLength | Infinity | Maximum length; cuts at a word boundary where possible. |
| replacements | {} | Substrings to swap before slugifying, e.g. { '&': 've' }. |
Works with both require and import:
import slugify from 'turkce-slugify';
// or
import { slugify } from 'turkce-slugify';TypeScript types are included; the options type is exported as SlugifyOptions.
Development
npm testRequires Node.js 18 or later. See CONTRIBUTING.md before opening a pull request.
