Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const defaultDocsifyConfig = () => ({
false
),
onlyCover: false,
sidebarPosition: /** @type {'left' | 'right'} */ ('left'),
plugins: /** @type {Plugin[]} */ ([]),
relativePath: false,
repo: /** @type {string} */ (''),
Expand Down
5 changes: 5 additions & 0 deletions src/core/render/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,11 @@ export function Render(Base) {
}
}

// Set sidebar position on body
if (config.sidebarPosition === 'right') {
dom.$.body.setAttribute('data-sidebar-position', 'right');
}

this._updateRender();
dom.body.classList.add('ready');
}
Expand Down
8 changes: 7 additions & 1 deletion src/themes/shared/_app.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ main {
> .content {
position: absolute;
inset: 0;
transition: left var(--duration-medium) ease;
transition: left var(--duration-medium) ease, right var(--duration-medium) ease;

body:has(.sidebar.show) & {
left: var(--sidebar-width);
}

/* Right sidebar position */
body[data-sidebar-position='right']:has(.sidebar.show) & {
left: 0;
right: var(--sidebar-width);
}

/* hideSidebar: true */
body:not:has(.sidebar) & {
position: static;
Expand Down
13 changes: 13 additions & 0 deletions src/themes/shared/_mq.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@
main > .content {
left: 0;
}

/* Right sidebar on mobile */
body[data-sidebar-position='right']:has(.sidebar.show) {
.app-nav {
left: auto;
right: 0;
}

main > .content {
left: auto;
right: 0;
}
}
}

body:has(.app-nav-merged) {
Expand Down
26 changes: 26 additions & 0 deletions src/themes/shared/_sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@
translate var(--duration-medium) ease,
visibility var(--duration-medium);

/* Right sidebar position */
[data-sidebar-position='right'] & {
left: auto;
right: 0;
translate: calc(0px + var(--sidebar-width));
border-right: none;
border-left: 1px solid var(--sidebar-border-color);
}

/* Non-webkit browsers: style scrollbar for consistency */
@supports (scrollbar-width: auto) {
&::-webkit-scrollbar {
Expand Down Expand Up @@ -236,6 +245,23 @@
translate var(--duration-medium) ease;
}

/* Right sidebar position */
body[data-sidebar-position='right'] & {
left: auto;
right: 0;

&.show {
translate: calc(0px - var(--sidebar-width));
}
}

body[data-sidebar-position='right']:has(.sidebar.show) & {
translate: calc(0px - var(--sidebar-width));
transition:
background 0s,
translate var(--duration-medium) ease;
}

body.sticky & {
position: fixed;
}
Expand Down