Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9220523

Browse filesBrowse files
authored
feat(render): add mergeNavbar option, close #125, #124 (#145)
1 parent b8100c0 commit 9220523
Copy full SHA for 9220523

11 files changed

+67-28Lines changed: 67 additions & 28 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎dev.html‎

Copy file name to clipboardExpand all lines: dev.html
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
loadNavbar: true,
3030
loadSidebar: true,
3131
name: 'docsify',
32-
subMaxLevel: 2
32+
subMaxLevel: 2,
33+
mergeNavbar: true
3334
}
3435
</script>
3536
<script src="/lib/docsify.js"></script>
Collapse file

‎docs/_navbar.md‎

Copy file name to clipboard
+4-4Lines changed: 4 additions & 4 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- :uk:
2-
- [:cn: 中文](/zh-cn/)
3-
- [:de: Deutsch](/de-de/)
4-
- [:uk: English](/)
1+
- Translations
2+
- [:cn: 中文](/zh-cn/)
3+
- [:de: Deutsch](/de-de/)
4+
- [:uk: English](/)
Collapse file

‎docs/configuration.md‎

Copy file name to clipboardExpand all lines: docs/configuration.md
+10Lines changed: 10 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -305,3 +305,13 @@ window.$docsify = {
305305
noEmoji: true
306306
}
307307
```
308+
309+
## merge-navbar
310+
311+
Navbar will be merged with the sidebar on smaller screens.
312+
313+
```js
314+
window.$docsify = {
315+
mergeNavbar: true
316+
}
317+
```
Collapse file

‎docs/de-de/_navbar.md‎

Copy file name to clipboardExpand all lines: docs/de-de/_navbar.md
-4Lines changed: 0 additions & 4 deletions
This file was deleted.
Collapse file

‎docs/de-de/configuration.md‎

Copy file name to clipboardExpand all lines: docs/de-de/configuration.md
+10Lines changed: 10 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -305,3 +305,13 @@ window.$docsify = {
305305
noEmoji: true
306306
}
307307
```
308+
309+
## merge-navbar
310+
311+
Navbar will be merged with the sidebar on smaller screens.
312+
313+
```js
314+
window.$docsify = {
315+
mergeNavbar: true
316+
}
317+
```
Collapse file

‎docs/index.html‎

Copy file name to clipboardExpand all lines: docs/index.html
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
executeScript: true,
3333
loadSidebar: true,
3434
loadNavbar: true,
35+
mergeNavbar: true,
3536
maxLevel: 4,
3637
name: 'docsify',
3738
search: {
Collapse file

‎docs/zh-cn/_navbar.md‎

Copy file name to clipboardExpand all lines: docs/zh-cn/_navbar.md
-4Lines changed: 0 additions & 4 deletions
This file was deleted.
Collapse file

‎docs/zh-cn/configuration.md‎

Copy file name to clipboardExpand all lines: docs/zh-cn/configuration.md
+11Lines changed: 11 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,14 @@ window.$docsify = {
315315
noEmoji: true
316316
}
317317
```
318+
319+
## merge-navbar
320+
321+
小屏设备下合并导航栏到侧边栏。
322+
323+
```js
324+
window.$docsify = {
325+
mergeNavbar: true
326+
}
327+
```
328+
Collapse file

‎src/core/config.js‎

Copy file name to clipboardExpand all lines: src/core/config.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const config = merge({
1717
autoHeader: false,
1818
executeScript: null,
1919
noEmoji: false,
20-
ga: ''
20+
ga: '',
21+
mergeNavbar: false
2122
}, window.$docsify)
2223

2324
const script = document.currentScript ||
Collapse file

‎src/core/render/index.js‎

Copy file name to clipboardExpand all lines: src/core/render/index.js
+14-6Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { markdown, sidebar, subSidebar, cover } from './compiler'
77
import { callHook } from '../init/lifecycle'
88
import { getBasePath, getPath, isAbsolutePath } from '../route/util'
99
import { isPrimitive } from '../util/core'
10+
import { isMobile } from '../util/env'
1011

1112
function executeScript () {
1213
const script = dom.findAll('.markdown-section>script')
@@ -153,12 +154,8 @@ export function initRender (vm) {
153154

154155
let el = dom.find(id)
155156
let html = ''
157+
let navAppendToTarget = dom.body
156158

157-
navEl.classList.add('app-nav')
158-
159-
if (!config.repo) {
160-
navEl.classList.add('no-badge')
161-
}
162159
if (!el) {
163160
el = dom.create(id)
164161
dom.appendTo(dom.body, el)
@@ -173,8 +170,19 @@ export function initRender (vm) {
173170
html += tpl.main(config)
174171
// Render main app
175172
vm._renderTo(el, html, true)
173+
174+
if (config.mergeNavbar && isMobile) {
175+
navAppendToTarget = dom.find('.sidebar')
176+
} else {
177+
navEl.classList.add('app-nav')
178+
179+
if (!config.repo) {
180+
navEl.classList.add('no-badge')
181+
}
182+
}
183+
176184
// Add nav
177-
dom.before(dom.body, navEl)
185+
dom.before(navAppendToTarget, navEl)
178186

179187
if (config.themeColor) {
180188
dom.$.head.innerHTML += tpl.theme(config.themeColor)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.