Fix name conflicts by using slugs for routing in isolated mode #998
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello @sapegin and all of you!
We're using styleguidist as a part of a big client project, and alost immediately ran in to problems with that the components all live in a global namespace, mentioned in #325, #919 and other places.
Requiring the specific components that you need is a bit ugly but works to solve naming conflicts in the examples. I'd like to take a stab at fixing this as well at some point, but we had a more critical problem with the routing.
When using styleguidist with the
pagePerSection
option set to true the routing use the section or component name instead of it's slug as a path/hash, meaning sections with conflicting names are completely unreachable.Since the slugs we're already in place to (I assume) handle this very problem when you don't use the
pagePerSection
option using them here as well seemed like a reasonable solution.The slug generation could possibly be improved further by prefixing child-section slugs with the parent section, allowing for for more meaningful and stable urls (e.g.
button/button
andtoolbar/button
instead ofbutton
and `button-1) but this might be a breaking change for some.