Files
maher 511fad8199
Build / run (push) Has been cancelled
Initial commit
2026-05-14 13:42:10 +02:00

22 lines
491 B
TypeScript
Executable File

import slugify from 'slugify';
export function slugifyString(
text: string,
replacement = '-',
strict = false,
): string {
if (!text) return text;
let slugified = slugify(text, {
lower: true,
replacement,
strict,
remove: /[*+~.()'"!:@?\|/\\#]/g,
});
// some chinese text might not get slugified properly,
// just replace whitespace with dash in that case
if (!slugified) {
slugified = text.replace(/\s+/g, '-').toLowerCase();
}
return slugified;
}