Slug creation with special letters

Hey, I tried overwriting HasSlug to add both lower and upper case 'Đ'=>'D' to $char_map but didnt work. My Model with title Đoković has slug okovic instead of dokovic. How can i add that additional letter?
4 Replies
ifox
ifox3w ago
Hi @toncek sorry for the delay. How did you try to override HasSlug? Does it work if you change directly in vendor?
toncek
toncekOP2w ago
Hey, I solved the issue. There is a function called slugify inside chunk-common.js and when you type in title it changes that input string depending on char map thats set inside function (if char is not inside that map it just skips to the next char). As you can see, now when I type in 'đ' it changes to 'dj'. I think I did not use correct way to solve this issue because I just copied vendor file chunk-common.js and added additional letter to that function (now I have vendor js file hardcoded). If you can suggest any better approach I would be thankful. I tried overriding that function with javascript but didn't succeed.
No description
ifox
ifox2w ago
To avoid the full built file hardcoded, here's what I would do in this case: - Only copy the filters.js file in your codebase https://github.com/area17/twill/blob/53f59c3623fca6f590baa3e0a260dd1edfdc187a/frontend/js/utils/filters.js#L15 - write a composer or npm script that copies it from your project to its location inside vendor/area17/twill - run php artisan twill:build in that script or after running it feel free to PR the change too we are aiming to unify the slug generation to be only happening in the backend at some point so we can remove that incomplete slugify function
toncek
toncekOP2w ago
Yeah, I thought you would do something like that. Okay. Thank you for help!
Want results from more Discord servers?
Add your server