404 error with a different http server for sidebar files
See original GitHub issueBug Report
I am using a different server than the one provided by docsify-cli (http-server) because of docsifyjs/docsify-cli#32. I find that the server keeps complaining about missing sidebar file for each route even though I have set a global sidebar file. Like so:
"GET foo/docs/bar/_sidebar.md" Error (404): "Not found"
The pages however work fine with the global sidebar loaded.
Steps to reproduce
Configurations that I have tried:
- Original
Files are in
/foo/docs
Homepage is/foo/docs/bar/README.md
I have a static sidebar at/foo/docs/_sidebar.md
window.$docsify = {
name: 'foo',
alias: {
'/':'/bar/',
},
basePath: '/foo/docs/',
relativePath: false,
loadSidebar: '_sidebar.md',
...
}
1a.
window.$docsify = {
name: 'foo',
alias: {
'/':'/bar/',
},
basePath: '/foo/docs/',
relativePath: false,
loadSidebar: '/_sidebar.md', //explicit slash
...
}
window.$docsify = {
name: 'foo',
alias: {
'/':'/bar/',
'/.*/_sidebar.md': '/_sidebar.md', // alias as in docs
},
basePath: '/foo/docs/',
relativePath: false,
loadSidebar: '_sidebar.md',
...
}
window.$docsify = {
name: 'foo',
alias: {
'/':'/bar/',
'/foo/docs/.*/_sidebar.md': '/foo/docs/_sidebar.md', // full alias which is probably incorrect
},
basePath: '/foo/docs/',
relativePath: false,
loadSidebar: '_sidebar.md',
...
}
In each of these cases, I get the 404 error.
What is current behaviour
There is an 404 error message for missing sidebar for each route, even when a global sidebar is defined.
What is the expected behaviour
There should be no error message! Docsify should not look for a local sidebar file.
Other relevant information
-
Bug does still occur when all/other plugins are disabled?
-
Your OS: Windows 10 x64
-
Node.js version: 14.17.5
-
npm/yarn version: 6.14.14
-
Browser version: Version 1.33.106 Chromium: 96.0.4664.110 (Official Build) (64-bit)
-
Docsify version: 4.12.1
-
Docsify plugins: None
Please create a reproducible sandbox
Cannot do so, as I need to change how the page is served. Help appreciated.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
Thanks @sy-records for your FAST reply. I was able to set “alias”: { ‘/.*/_sidebar.md’: ‘/_sidebar.md’ }, in the JSON object called
window.$docsify
in index.html and that does seem to solve the issue. However since I am using thec4Builder
which callsdocsify
and generates theindex.html
I will have to figure out how to get this included by default.Was I correct in adding to the
window.$docsify
object in index.html? Was there some other place to add it?Thanks again!
Try setting alias