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

fix: local documentation #188

Merged
merged 1 commit into from
Sep 11, 2024
Merged

fix: local documentation #188

merged 1 commit into from
Sep 11, 2024

Conversation

jackwilsdon
Copy link
Contributor

express-static prefers directories over files when using the extensions option, meaning an extensionless route will always route to the directory instead of the file (expressjs/serve-static#138). This causes URLs like http://localhost:9078/docs/docs/configuration to work when navigating from other pages (due to it being a SPA), but on reload it redirects to http://localhost:9078/docs/docs/configuration/ and returns a 404 (note the trailing slash).

This PR re-enables trailing slashes, which turns this structure:

docs
|- configuration
|  |- plex.html
|- configuration.html

Into:

docs
|- configuration
   |- plex
   |  |- index.html
   |- index.html

This fixes local docs (served by the backend).

I've deployed it to GH pages here: https://jackwilsdon.github.io/multi-scrobbler/

All existing (normal) URLs will work - GitHub Pages will just add a trailing slash via a 301 redirect. The only URLs that will no longer work are the ones with extensions (e.g. https://jackwilsdon.github.io/multi-scrobbler/docs/configuration.html), but nothing on the site links to that anyway from what I can tell.

We could only set this option to true for GitHub pages, but it seemed neater to use the same option for both.

Checklist before requesting a review

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Describe your changes

Issue number and link, if applicable

express-static prefers directories over files when using the extensions
option, meaning an extensionless route will always route to the
directory instead of the file (expressjs/serve-static#138).
@FoxxMD FoxxMD merged commit d7981e7 into FoxxMD:master Sep 11, 2024
4 checks passed
@FoxxMD
Copy link
Owner

FoxxMD commented Sep 11, 2024

Awesome! Thanks for finding and fixing that.

@jackwilsdon jackwilsdon deleted the fix-local-docs branch September 11, 2024 12:34
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