Open viicslen opened 7 months ago
I like this idea ... but have a few thoughts:
Instead of making this a new configuration setting, we could just change the way the current unique
setting works:
unique
is false
, do nothingunique
is true
, add a suffixunique
is a callable, use thatFor something like this, I might extract all the existing code that handles suffixes into it's own class, and just make that the default value for unique
, so we're always running a callable ... either the built-in one, or a custom one like you envisioned.
I'm also curious ... what was your use-case for this? And could we add some tests for your PR?
Thanks!
This pull request introduces a new feature to allow for personalization of unique slugs. If the slug is not unique and you want to try to make it unique by replacing some other parts of the slug instead of adding a suffic, you can set the
uniqueUsing
configuration option to a closure which accepts the base slug, the separator, and a Collection of the other "similar" slugs as arguments. The closure should return the new unique slug to use, if the slug is still not unique, it will append a suffix to the returned slug.Missing:
README.md
, etc.)