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

[Bug]: Unreliable behavour of slashes \ in sidebar configuration for page paths #740

Open
toteto opened this issue Mar 7, 2024 · 2 comments
Labels
🐞 bug Something isn't working

Comments

@toteto
Copy link
Contributor

toteto commented Mar 7, 2024

Version

System:
    OS: macOS 14.3.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 1.12 GB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Browsers:
    Chrome: 122.0.6261.111
    Safari: 17.3.1
  npmPackages:
    rspress: ^1.0.0 => 1.13.2

Details

I have a sidebar configuration in the rspress.config.ts file. My content structure makes more sense to be configured this way instead of _meta.json. Following the sidebar configuration from the docs, I have the following config (also available in the reproduce link)

// Folder structure (from the starter template)
// docs 
//   guide
//     index.md
//   hello.md

themeConfig: {
    sidebar: {
      '/': [
        { text: "Markdown & MDX", link: '/guide'},
        { text: "Hello", link: '/hello'},
      ]
    },

I am hosting this in GitHub Pages at this link: https://toteto.github.io/test-rspress/

When I navigate to https://toteto.github.io/test-rspress/guide/ my expectations is to get the guide/index.md page with the sidebar on the side with both the Markdown & MDX and Hello items. However the case is that the sidebar is not being shown.

image

In order to get it working, i need to navigate to https://toteto.github.io/test-rspress/guide.html

Another way to get it working is to change the link to include a slash at the end

-{ text: "Markdown & MDX", link: '/guide'},
+{ text: "Markdown & MDX", link: '/guide/'},

Or to have the full path

-{ text: "Markdown & MDX", link: '/guide'},
+{ text: "Markdown & MDX", link: '/guide/index.html'},

To me it looks like it is some sidebar matching issues in the render logic for the sidebar

Reproduce link

https://github.com/toteto/test-rspress/tree/gh-pages

Reproduce Steps

  1. Create sidebar config with items as described in the config
  2. Navigate to the site or deploy it to GitHub pages
  3. The sidebar is not shown
@toteto toteto added the 🐞 bug Something isn't working label Mar 7, 2024
@sanyuan0704
Copy link
Collaborator

Take the ending slash or not has different means:
/guide -> /guide.md(x)
/guide/ -> /guide/index.md(x)

@toteto
Copy link
Contributor Author

toteto commented Mar 8, 2024

Take the ending slash or not has different means: /guide -> /guide.md(x) /guide/ -> /guide/index.md(x)

Why is this the case? Personally think that it is easier to configure and think about the configuration if /guide and /guide/ pointed to the same thing where there is no conflicting files,

For example if there is guide.md and guide/index.md, maybe it should have the distinction, but in cases where there is just one, it just creates case for confusion.

Also maybe this case should be documented in the API for sidebar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants