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

pagePerSection links break when section name includes a "/" #1332

Closed
stonebk opened this issue Apr 11, 2019 · 9 comments
Closed

pagePerSection links break when section name includes a "/" #1332

stonebk opened this issue Apr 11, 2019 · 9 comments

Comments

@stonebk
Copy link

stonebk commented Apr 11, 2019

Current behavior

If you have a forward slash in your section name, the pagePerSection links are all broken, resulting in "Page not found". Removing the forward slashes in the names fixes the issue.

To reproduce

Simple styleguide.config.js:

module.exports = {
    pagePerSection: true,
    sections: [{
        name: '@foo/components'
    }, {
        name: '@bar/components'
    }]
};

Expected behavior

Links should work for any text in a section name field. Probably just need to urlencode the string.

@stonebk stonebk changed the title pagePerSection links break when section name has includes a "/" pagePerSection links break when section name has includes a "/" Apr 11, 2019
@stonebk stonebk changed the title pagePerSection links break when section name has includes a "/" pagePerSection links break when section name includes a "/" Apr 11, 2019
@sapegin
Copy link
Member

sapegin commented Apr 18, 2019

Feel free to send a pull request with a fix.

mendrew added a commit to mendrew/react-styleguidist that referenced this issue Jun 14, 2019
If you have a forward slash in your section name, the pagePerSection links are all broken,
 resulting in "Page not found".
Removing the forward slashes in the names fixes the issue.

For example:
  pagePerSection links break when section name includes a "/", like `name: '@foo/components'`

Solution is just encode name in the getUrl and then correctly
decode it in the router logic.

iss: styleguidist#1332
@sapegin sapegin added the bug label Jun 15, 2019
@styleguidist-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 9.1.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@stonebk
Copy link
Author

stonebk commented Jun 18, 2019

This appears to have fixed the top level section link, but any sub-links within that section are still unencoded and result in "Page not found".

@mendrew
Copy link
Contributor

mendrew commented Jun 18, 2019

@stonebk could you please give an example of the config file to get an exact idea of sub-links you are talking about?
I was able to reproduce your problem by applying your config from the description on Styleguidist sections example. I'd be glad to fix this as well.

@stonebk
Copy link
Author

stonebk commented Jun 18, 2019

@mendrew it looks something like this:

{
    "webpackConfig": { ... },
    "styleguideComponents": { ... },
    "title": "Foundation Team APIs",
    "usageMode": "expand",
    "require": [ ... ],
    "pagePerSection": true,
    "sections": [
        {
            "name": "Introduction",
            "content": "docs/introduction.md"
        },
        {
            "name": "@zillow/zrs-activation",
            "sections": [
                {
                    "name": "Components",
                    "components": "/Users/stonebk/foundation-site/node_modules/@zillow/zrs-activation/src/components/**/[A-Z]*.{js,jsx,ts,tsx}"
                }
            ]
        },
        {
            "name": "@zillow/zrs-profile",
            "sections": [
                {
                    "name": "Components",
                    "components": "/Users/stonebk/foundation-site/node_modules/@zillow/zrs-profile/src/components/**/[A-Z]*.{js,jsx,ts,tsx}"
                }
            ]
        },
    ]
}

With that config, both the "Components" link under the section name, and all the links under "Components" have unencoded urls.

@mendrew
Copy link
Contributor

mendrew commented Jun 18, 2019

Awesome, thank you, I'll take a look.

mendrew added a commit to mendrew/react-styleguidist that referenced this issue Jun 22, 2019
Follow up of styleguidist#1332
This appears to have fixed the top level section link,
but any sub-links within that section are still unencoded and result
in "Page not found".
sapegin pushed a commit that referenced this issue Jun 24, 2019
Follow up of #1332. This appears to have fixed the top level section link, but any sub-links within that section are still unencoded and result in "Page not found".
@mendrew
Copy link
Contributor

mendrew commented Jun 24, 2019

Hi @stonebk. The fix has been released in v9.1.10.
Could you please take a look?

@stonebk
Copy link
Author

stonebk commented Jun 24, 2019

@mendrew, all better now! Thanks so much!

@mendrew
Copy link
Contributor

mendrew commented Jun 24, 2019

Awesome, you're welcome! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants