-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Use absoluteURL instead of relativeURL for next/prev links #783
Conversation
Deploy preview for docusaurus-preview ready! Built with commit b35c2bd |
2206d9d
to
e5cca33
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Just one question.
lib/core/DocsLayout.js
Outdated
@@ -47,7 +47,8 @@ class DocsLayout extends React.Component { | |||
description={content.trim().split('\n')[0]} | |||
language={metadata.language} | |||
version={metadata.version} | |||
metadata={metadata}> | |||
metadata={metadata} | |||
removeTrailingSlash={true}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would there be time when this would ever be set to false
? Just wondering if we need a prop at all and we just always remove the trailing slash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question I have as Joel. I don't think this is the best way to fix though.
@endiliey I think the proper fix would be to generate absolute URLs for next/prev like what we do for the sidebar.
Actually we always use relative url for next/prev in sidebar. Docusaurus 1.2.0 Docusaurus < 1.2.0 I do feel my solution of removing trail slashes is a bit hacky though 😃. (I'm removing it) Anyway, I'm changing it to use absolute URL with my latest commit so this bug will no longer exist 👍 |
@endiliey Do we have next/prev in sidebar? What I mean is that in the left sidebar nav, we use absolute URLs, which is the approach I feel is better and we should do that for the next/prev buttons within the doc page. |
@yangshun Sorry. I think I misunderstood your comment before. I mean next/prev button in docs 😢 Anyway, changes updated. We now use absolute URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this!
Motivation
Our docs prev/next button is build with relative path in mind. But relative path is really
relative
If our current url is https://babeljs.io/docs/en/babel-plugin-transform-runtime
<a href='babel-register'/>
will translate to https://babeljs.io/docs/en/babel-registerIf our current url is https://babeljs.io/docs/en/babel-plugin-transform-runtime/
<a href='babel-register'/>
will translate to https://babeljs.io/docs/en/babel-plugin-transform-runtime/babel-register which is wrongThe fix is to use absolute url 😄
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Before
Go to https://docusaurus.io/docs/en/installation/ (notice the ending slash
/
) and clickprevious/next
button, 404 pageAfter
Go to http://localhost:3000/docs/en/installation/ (notice the ending slash
/
) and clickprevious/next
button, no problem