Redirect /subdir to /subdir/ when the page is given by docs/subdir/index.md#274
Merged
Redirect /subdir to /subdir/ when the page is given by docs/subdir/index.md#274
Conversation
…dex.md. Otherwise links seen in preview under /subdir can look correct, but will fail in the build. To test, run: > yarn dev --root test/input/build/multi/ and open http://127.0.0.1:3000/subsection
mbostock
requested changes
Nov 29, 2023
Member
mbostock
left a comment
There was a problem hiding this comment.
This causes one more redirect than necessary in the /subdir/index and /subdir/index.html case, which first get redirected to /subdir, and then to /subdir/. Let’s add the trailing slash on L127 too?
Given a /dir/index(.html) path, we redirect the browser to /dir/ if there is a dir/index.md file, otherwise to /dir. This accomodates /javascript in the documentation as well as test/input/build/multi/subsection/
Contributor
Author
|
Done. But more complicated than it seems! Let's also remove a redundant call to await access(join(path, "index") + ".md", constants.R_OK); |
mbostock
approved these changes
Nov 29, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Otherwise links seen in preview under /subdir can look correct, but will fail in the build.
To test, run:
(extracted from #257)