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

Redirect /subdir to /subdir/ when the page is given by docs/subdir/index.md #274

Merged
merged 3 commits into from
Nov 29, 2023

Conversation

Fil
Copy link
Contributor

@Fil Fil commented Nov 29, 2023

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

(extracted from #257)

…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
@Fil Fil requested a review from mbostock November 29, 2023 15:52
Copy link
Member

@mbostock mbostock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/
@Fil
Copy link
Contributor Author

Fil commented Nov 29, 2023

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 mbostock merged commit 052835b into main Nov 29, 2023
1 check passed
@mbostock mbostock deleted the fil/subsection-redirect branch November 29, 2023 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants