-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
when using relativePath: true, links on the sidebar are always relative to the current page #1139
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
Comments
I have considered whether this behavior was intended to cover some specific scenario, but could not think of any in which it would be beneficial. I have browsed the code, the link rendered uses the current route to resolve relative links: docsify/src/core/render/compiler/link.js Line 20 in b2e6123
It has no access to current file for the sidebar (I suppose this is also true for the navbar). docsify/src/core/fetch/index.js Line 8 in b2e6123
I could not think of an easy solution. I have considered the following:
I did not check yet how to create automated tests for this. |
Thanks for the detailed issue. 💯 If I am not wrong, when you are in if this is, then its the intended behavior as sidebar is always at root (of the current folder) so the base path will be the current path. if you want to go up one directory in order to render that page you need to give related path from where the sidebar is. |
Hi @anikethsaha
Right, if I understood that correctly. To give more details: Now, in my example the sidebar markdown file is always at root (not of the current folder, but https://dellagustin-sap.github.io/docsify-relative-path-bug-report/sidebar.md) - and that is why I think that the links on the sidebar should be resolved relative to where the sidebar file was found. About:
I am not sure what you mean with always here, because
|
sorry, I thought you had the aliases setup to fallback to root. this needs investigation. I will check once again. cc @docsifyjs/reviewers , thoughts ? |
No actually meant this function: docsify/src/core/fetch/index.js Line 8 in b2e6123
|
ok cool, I will check that soon for sure 👍 . |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I think I can solve this issue. My strategy is to pass a function loadNested(path, qs, file, next, vm, first) {
path = first ? path : path.replace(/\/$/, '');
path = getParentPath(path);
if (!path) {
return;
}
get(
vm.router.getFile(path + file) + qs,
false,
vm.config.requestHeaders
).then(
next,
function (_) { return loadNested(path, qs, file, (r) => next(r, true), vm); });
}
...
var fn = function (result, isParent) {
this$1._renderSidebar(result, isParent);
cb();
};
// Load sidebar
loadNested(path, qs, loadSidebar, fn, this$1, true);
proto._renderSidebar = function(text, isParent) {
...
this._renderTo('.sidebar-nav', that.compiler.sidebar(result, maxLevel, isParent));
...
}
Compiler.prototype.sidebar = function sidebar (text, level, isParent) {
...
if (text) {
html = this.compile(text, isParent && {baseUrl: '../'}); // using this to modify marked.setOptions
}
... An alternative could be to pass the But I have a couple of questions:
|
I was having this issue but was able to resolve it for now by writing the i.e.
becomes:
note, |
I'm having this issue as well. Another workaround is to make the paths in |
I too have been bitten by this. This will be officially solved in #1684 with a new option (for backwards compatibility, so that existing options like |
Bug Report
this is a duplicate of #925, that was closed automatically.
Steps to reproduce
I have prepared an example here: https://dellagustin-sap.github.io/docsify-relative-path-bug-report/#/
Click first on Subpage1 - Absolute (on the sidebar), then on Subpage1 - Relative
What is current behaviour
A 404 page is shown
What is the expected behaviour
Subpage 1 should be shown
Other relevant information
Bug does still occur when all/other plugins are disabled?
Your OS: Windows 10 home
Node.js version: N/A
npm/yarn version: N/A
Browser version: Google Chrome 80.0.3987.163
Docsify version: 4.11.3
Docsify plugins: none
Please create a reproducible sandbox
https://dellagustin-sap.github.io/docsify-relative-path-bug-report/#/
Mention the docsify version in which this bug was not present (if any)
The text was updated successfully, but these errors were encountered: