diff --git a/docs/configuration.md b/docs/configuration.md index 7a65553a3..a708d69d0 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -108,9 +108,10 @@ window.$docsify = { ## hideSidebar - Type : `Boolean` -- Default: `true` +- Default: `false` -This option will completely hide your sidebar and won't render any content on the side. +This option will completely hide your sidebar and won't render any content on the side. +Meanwhile, the search plugin won't work either. ```js window.$docsify = { diff --git a/src/core/config.js b/src/core/config.js index 2d23f5db2..1429b4977 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -11,6 +11,7 @@ export default function(vm) { subMaxLevel: 0, loadSidebar: null, loadNavbar: null, + hideSidebar: false, homepage: 'README.md', coverpage: '', basePath: '', diff --git a/src/core/fetch/index.js b/src/core/fetch/index.js index 1853a0297..dde21afe9 100644 --- a/src/core/fetch/index.js +++ b/src/core/fetch/index.js @@ -85,8 +85,11 @@ export function fetchMixin(proto) { return path404; }; - proto._loadSideAndNav = function(path, qs, loadSidebar, cb) { + proto._loadSideAndNav = function(path, qs, loadSidebar, hideSidebar, cb) { return () => { + if (hideSidebar) { + return; + } if (!loadSidebar) { return cb(); } @@ -104,7 +107,12 @@ export function fetchMixin(proto) { proto._fetch = function(cb = noop) { const { path, query } = this.route; const qs = stringifyQuery(query, ['id']); - const { loadNavbar, requestHeaders, loadSidebar } = this.config; + const { + loadNavbar, + requestHeaders, + loadSidebar, + hideSidebar, + } = this.config; // Abort last request const file = this.router.getFile(path); @@ -120,7 +128,7 @@ export function fetchMixin(proto) { this._renderMain( text, opt, - this._loadSideAndNav(path, qs, loadSidebar, cb) + this._loadSideAndNav(path, qs, loadSidebar, hideSidebar, cb) ), _ => { this._fetchFallbackPage(path, qs, cb) || this._fetch404(file, qs, cb); @@ -197,7 +205,12 @@ export function fetchMixin(proto) { }; proto._fetchFallbackPage = function(path, qs, cb = noop) { - const { requestHeaders, fallbackLanguages, loadSidebar } = this.config; + const { + requestHeaders, + fallbackLanguages, + loadSidebar, + hideSidebar, + } = this.config; if (!fallbackLanguages) { return false; @@ -219,7 +232,7 @@ export function fetchMixin(proto) { this._renderMain( text, opt, - this._loadSideAndNav(path, qs, loadSidebar, cb) + this._loadSideAndNav(path, qs, loadSidebar, hideSidebar, cb) ), () => this._fetch404(path, qs, cb) ); @@ -255,7 +268,7 @@ export function fetchMixin(proto) { } export function initFetch(vm) { - const { loadSidebar } = vm.config; + const { loadSidebar, hideSidebar } = vm.config; // Server-Side Rendering if (vm.rendered) { @@ -264,7 +277,7 @@ export function initFetch(vm) { activeEl.parentNode.innerHTML += window.__SUB_SIDEBAR__; } - vm._bindEventOnRendered(activeEl); + !hideSidebar && vm._bindEventOnRendered(activeEl); vm.$resetEvents(); callHook(vm, 'doneEach'); callHook(vm, 'ready'); diff --git a/src/core/render/index.js b/src/core/render/index.js index 42e62ba96..8e40cfc53 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -48,7 +48,7 @@ function renderMain(html) { this._renderTo('.markdown-section', html); // Render sidebar with the TOC - !this.config.loadSidebar && this._renderSidebar(); + !this.config.hideSidebar && !this.config.loadSidebar && this._renderSidebar(); // Execute markdown