diff --git a/docs/configuration.md b/docs/configuration.md index 7b61752984..23ca300b93 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -306,6 +306,20 @@ window.$docsify = { }; ``` +## sidebarPosition + +- Type: `String` +- Default: `'left'` + +Controls which side of the page displays the sidebar. Set this to `'right'` to +place the sidebar and its toggle on the right. + +```js +window.$docsify = { + sidebarPosition: 'right', +}; +``` + ## homepage - Type: `String` diff --git a/src/core/config.js b/src/core/config.js index b2e2fdb9e2..2648a9824e 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -58,6 +58,7 @@ const defaultDocsifyConfig = () => ({ skipLink: /** @type {false | string | Record} */ ( 'Skip to main content' ), + sidebarPosition: /** @type {'left' | 'right'} */ ('left'), subMaxLevel: 0, vueComponents: /** @type {Record} */ ({}), vueGlobalOptions: /** @type {Record} */ ({}), diff --git a/src/core/render/tpl.js b/src/core/render/tpl.js index 88b732a78f..b4c6de3b5c 100644 --- a/src/core/render/tpl.js +++ b/src/core/render/tpl.js @@ -36,18 +36,20 @@ export function corner(data, cornerExternalLinkTarget) { * @returns {String} HTML of the main content */ export function main(config) { - const { hideSidebar, name } = config; + const { hideSidebar, name, sidebarPosition } = config; + const sidebarPositionClass = + sidebarPosition === 'right' ? ' sidebar-right' : ''; // const name = config.name ? config.name : ''; const aside = /* html */ hideSidebar ? '' : ` - -