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 invalid links when served with trailing slash #212

Merged
merged 1 commit into from
Oct 9, 2021

Conversation

eddsby
Copy link

@eddsby eddsby commented Oct 9, 2021

The Issue:

Visit this URL directly: https://docs.darklang.com/contributing/getting-started
301 Redirects to (note trailing slash): https://docs.darklang.com/contributing/getting-started/

The internal links on this page are now invalid, for example - https://docs.darklang.com/contributing/getting-started/if-you-dont-know-ocaml

if-you-dont-know-ocaml is getting appended to https://docs.darklang.com/contributing/getting-started/

If you navigate to this page through JS, avoiding the 301 redirect and actually arriving at https://docs.darklang.com/contributing/getting-started (no trailing slash) then if-you-dont-know-ocaml is getting appended to https://docs.darklang.com/contributing/ and the link is correct.

I encountered this by navigating to the contributor docs from the dark README link, https://darklang.github.io/docs/contributing/getting-started, which ultimately leaves you on the trailing slash page with invalid links.

See some discussion here - facebook/docusaurus#3372 and facebook/docusaurus#5250.

The simplest fix seems to be linking directly to documents instead of using URL paths, as I have applied here for just the contributing pages.

There is a trailingSlash added from version 2.0.0-beta.df8a900f9 onwards, however upgrading to this seemed to have numerous breaking changes.

Relative file paths resolve to the correct links when slashes are
appended to URLs. Relative links do not.

https://docusaurus.io/docs/docs-markdown-features#referencing-other-documents
@pbiggar
Copy link
Member

pbiggar commented Oct 9, 2021

Very helpful thanks! I didn't know you could link to files - TIL.

There are a few linting errors in CI that you can see here - I'll merge as soon as it goes green.

@eddsby
Copy link
Author

eddsby commented Oct 9, 2021

I'm getting those same linting errors on the main branch, I don't think they're related to this change. I could look at fixing though

@pbiggar
Copy link
Member

pbiggar commented Oct 9, 2021

Oh, that makes sense - I've been pushing to main a bit 😬

@pbiggar pbiggar merged commit a5405a7 into darklang:main Oct 9, 2021
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.

None yet

2 participants