Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to support custom slug library #17

Open
svengau opened this issue Feb 10, 2020 · 5 comments
Open

Add an option to support custom slug library #17

svengau opened this issue Feb 10, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@svengau
Copy link

svengau commented Feb 10, 2020

This plugin is great, unfortunately we can't provide a custom function like mongoose-slug-plugin.

I would like to use limax instead of speakingurl to generate slugs for Asian languages.

@YuriGor
Copy link
Owner

YuriGor commented Feb 10, 2020

Hi, I have no time for doing this right way but will be happy to assist you, if you want to implement such an option and propose PR.
It will be as easy as adding one check in one place in the code - if options object has 'getSlug' the use it instead of default speakingUrl.
Most of the time will be needed for writing some tests to keep a high level of test coverage.
For you, as a native speaker familiar with a lib you wanna use it will be much more efficient.

@svengau
Copy link
Author

svengau commented Feb 11, 2020

Hi @YuriGor and thanks for the feedback.

I've started a PR, added the slugger option, and write the test. But then I've realized the existing tests are using mongoose.plugin(..) at many places to register the plugin globally.
I've tried to register the plugin manually at the model level, for each model in the test, but didn't succeed to make it work. Existing tests are failing. And frankly, I'm wondering how the test suite really covers all cases with a global plugin registration in mongoose...

Anyway, I don't have time neither to fix all tests. Here is the commit if anyone wants to try:

https://github.com/svengau/mongoose-slug-updater/commit/167c4005c29a4491bb923842a687164c39047c12

@YuriGor
Copy link
Owner

YuriGor commented Feb 28, 2020

Sorry for the late response, hope your fork works for you well, I'll take a look at it as soon as I'll be able to, but it'll be actually not so soon.
Could you please share more string pairs before/after slugify here in comments,
I see only one example in your fork.
Maybe some more examples with punctuation and special characters (if punctuation exists in your language) and also examples of strings mixed with English words.

@YuriGor
Copy link
Owner

YuriGor commented Mar 31, 2020

Still have no time to do it well, sorry :(
m.b. bit later

@svengau
Copy link
Author

svengau commented Mar 31, 2020

Hi @YuriGor no worries, I don't have much time neither on my side.

@YuriGor YuriGor added the enhancement New feature or request label Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants