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

cleanUrls does not check for nested index.md #1770

Closed
3 tasks done
MarkusKeck opened this issue Jan 7, 2023 · 1 comment · Fixed by #1772
Closed
3 tasks done

cleanUrls does not check for nested index.md #1770

MarkusKeck opened this issue Jan 7, 2023 · 1 comment · Fixed by #1772
Labels
bug Something isn't working build Related to the build system

Comments

@MarkusKeck
Copy link
Collaborator

MarkusKeck commented Jan 7, 2023

Describe the bug

Vitepress should check for a nested index.md if no file for the current url exists

Reproduction

  1. Create a folder test
  2. Create a index.md file inside the test folder

Call the URL http://localhost:5173/test

http://localhost:5173/test -> 404 page not found
http://localhost:5173/test/ -> index.md gets found

This behavior makes sense from a file and folder perspective, but not from an url perspective.
URLs should point to the same resource regardless of using a trailing slash or not

I thought this gets handled with the cleanUrls setting
https://vitepress.vuejs.org/config/app-configs#cleanurls-experimental

In my opinion with-subfolders should check for an index.md file and without-subfolders should not.

Expected behavior

If no file gets found for the currently called url vitepress should check if the called folder contains an index file

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (32) x64 AMD Ryzen 9 3950X 16-Core Processor
    Memory: 44.27 GB / 63.91 GB
  Binaries:
    Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.7.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (108.0.1462.76)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    vitepress: ^1.0.0-alpha.13 => 1.0.0-alpha.35

Additional context

No response

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@MarkusKeck MarkusKeck added the bug: pending triage Maybe a bug, waiting for confirmation label Jan 7, 2023
@brc-dd brc-dd added bug Something isn't working build Related to the build system and removed bug: pending triage Maybe a bug, waiting for confirmation labels Jan 7, 2023
@brc-dd
Copy link
Member

brc-dd commented Jan 7, 2023

We actually attempted to fix this in #1575. But looks like I missed the opposite case, I'll create a PR soon. However, it is worth noting that the fix doesn't work in dev, it works only in prod, and whether to redirect from trailing slash to non-trailing slash, the choice is up to you, you'll need to configure your hosting provider accordingly. Also, page relative URLs (incl. assets if any) might break as it is a browser feature (will be resolved differently depending if one has trailing slash or not).

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working build Related to the build system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants