mirror of
https://github.com/wahyd4/docsify.git
synced 2026-08-09 21:36:10 +10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
928bf9b51c | ||
|
|
23e9d9170f | ||
|
|
9b7e5f5814 | ||
|
|
432bcfb54b | ||
|
|
4f98497284 | ||
|
|
9220523a40 | ||
|
|
b8100c0755 | ||
|
|
be0230ebe9 | ||
|
|
aa6d2afce8 | ||
|
|
a706203879 | ||
|
|
fbc75bdb95 | ||
|
|
5af174bd20 |
@@ -1,3 +1,18 @@
|
||||
|
||||
# 3.6.1 / 2017-04-09
|
||||
|
||||
* feat(event): Collapse the sidebar when click outside element in the small screen
|
||||
|
||||
# 3.6.0 / 2017-04-09
|
||||
|
||||
* feat(render): add mergeNavbar option, close ([#125](https://github.com/QingWei-Li/docsify/issues/125)
|
||||
|
||||
# 3.5.2/ 2017-04-05
|
||||
|
||||
* add optional current route param to toURL and use it to properly compose local anchor links
|
||||
* fix code style by removing semicolons
|
||||
* in toURL test for anchor links and if so prepend the currentPath to the generated path. fixes ([#142](https://github.com/QingWei-Li/docsify/issues/142))
|
||||
|
||||
# 3.5.1 / 2017-03-25
|
||||
|
||||
* fix: .md file extension regex
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
loadNavbar: true,
|
||||
loadSidebar: true,
|
||||
name: 'docsify',
|
||||
subMaxLevel: 2
|
||||
subMaxLevel: 2,
|
||||
mergeNavbar: true
|
||||
}
|
||||
</script>
|
||||
<script src="/lib/docsify.js"></script>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||

|
||||
|
||||
# docsify <small>3.5</small>
|
||||
# docsify <small>3.6</small>
|
||||
|
||||
> A magical documentation site generator.
|
||||
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
- :uk:
|
||||
- [:cn: 中文](/zh-cn/)
|
||||
- [:de: Deutsch](/de-de/)
|
||||
- [:uk: English](/)
|
||||
- Translations
|
||||
- [:cn: 中文](/zh-cn/)
|
||||
- [:de: Deutsch](/de-de/)
|
||||
- [:uk: English](/)
|
||||
|
||||
@@ -305,3 +305,13 @@ window.$docsify = {
|
||||
noEmoji: true
|
||||
}
|
||||
```
|
||||
|
||||
## merge-navbar
|
||||
|
||||
Navbar will be merged with the sidebar on smaller screens.
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
mergeNavbar: true
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
- :de:
|
||||
- [:cn: 中文](/zh-cn/)
|
||||
- [:de: Deutsch](/de-de/)
|
||||
- [:uk: English](/)
|
||||
@@ -305,3 +305,13 @@ window.$docsify = {
|
||||
noEmoji: true
|
||||
}
|
||||
```
|
||||
|
||||
## merge-navbar
|
||||
|
||||
Navbar will be merged with the sidebar on smaller screens.
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
mergeNavbar: true
|
||||
}
|
||||
```
|
||||
@@ -32,6 +32,7 @@
|
||||
executeScript: true,
|
||||
loadSidebar: true,
|
||||
loadNavbar: true,
|
||||
mergeNavbar: true,
|
||||
maxLevel: 4,
|
||||
name: 'docsify',
|
||||
search: {
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
- :cn:
|
||||
- [:cn: 中文](/zh-cn/)
|
||||
- [:de: Deutsch](/de-de/)
|
||||
- [:uk: English](/)
|
||||
@@ -315,3 +315,14 @@ window.$docsify = {
|
||||
noEmoji: true
|
||||
}
|
||||
```
|
||||
|
||||
## merge-navbar
|
||||
|
||||
小屏设备下合并导航栏到侧边栏。
|
||||
|
||||
```js
|
||||
window.$docsify = {
|
||||
mergeNavbar: true
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
+30
-15
@@ -76,7 +76,8 @@ var config = merge({
|
||||
autoHeader: false,
|
||||
executeScript: null,
|
||||
noEmoji: false,
|
||||
ga: ''
|
||||
ga: '',
|
||||
mergeNavbar: false
|
||||
}, window.$docsify);
|
||||
|
||||
var script = document.currentScript ||
|
||||
@@ -380,14 +381,18 @@ function parse (path) {
|
||||
* to URL
|
||||
* @param {string} path
|
||||
* @param {object} qs query params
|
||||
* @param {string} currentRoute optional current route
|
||||
*/
|
||||
function toURL (path, params) {
|
||||
function toURL (path, params, currentRoute) {
|
||||
var local = currentRoute && path[0] === '#';
|
||||
var route = parse(replaceSlug(path));
|
||||
|
||||
route.query = merge({}, route.query, params);
|
||||
path = route.path + stringifyQuery(route.query);
|
||||
path = path.replace(/\.md(\?)|\.md$/, '$1');
|
||||
|
||||
if (local) { path = currentRoute + path; }
|
||||
|
||||
return cleanPath('#/' + path)
|
||||
}
|
||||
|
||||
@@ -411,17 +416,20 @@ var title = $.title;
|
||||
* Toggle button
|
||||
*/
|
||||
function btn (el) {
|
||||
var toggle = function () { return body.classList.toggle('close'); };
|
||||
var toggle = function (_) { return body.classList.toggle('close'); };
|
||||
|
||||
el = getNode(el);
|
||||
on(el, 'click', toggle);
|
||||
on(el, 'click', function (e) {
|
||||
e.stopPropagation();
|
||||
toggle();
|
||||
});
|
||||
|
||||
var sidebar = getNode('.sidebar');
|
||||
|
||||
on(sidebar, 'click', function () {
|
||||
isMobile && toggle();
|
||||
setTimeout(function () { return getAndActive(sidebar, true, true); }, 0);
|
||||
});
|
||||
isMobile && on(body, 'click', function (_) { return body.classList.contains('close') && toggle(); }
|
||||
);
|
||||
on(sidebar, 'click', function (_) { return setTimeout((function (_) { return getAndActive(sidebar, true, true); }, 0)); }
|
||||
);
|
||||
}
|
||||
|
||||
function sticky () {
|
||||
@@ -3025,7 +3033,7 @@ renderer.code = function (code, lang) {
|
||||
renderer.link = function (href, title, text) {
|
||||
var blank = '';
|
||||
if (!/:|(\/{2})/.test(href)) {
|
||||
href = toURL(href);
|
||||
href = toURL(href, null, currentPath);
|
||||
} else {
|
||||
blank = ' target="_blank"';
|
||||
}
|
||||
@@ -3259,12 +3267,8 @@ function initRender (vm) {
|
||||
|
||||
var el = find(id);
|
||||
var html = '';
|
||||
var navAppendToTarget = body;
|
||||
|
||||
navEl.classList.add('app-nav');
|
||||
|
||||
if (!config.repo) {
|
||||
navEl.classList.add('no-badge');
|
||||
}
|
||||
if (!el) {
|
||||
el = create(id);
|
||||
appendTo(body, el);
|
||||
@@ -3279,8 +3283,19 @@ function initRender (vm) {
|
||||
html += main(config);
|
||||
// Render main app
|
||||
vm._renderTo(el, html, true);
|
||||
|
||||
if (config.mergeNavbar && isMobile) {
|
||||
navAppendToTarget = find('.sidebar');
|
||||
} else {
|
||||
navEl.classList.add('app-nav');
|
||||
|
||||
if (!config.repo) {
|
||||
navEl.classList.add('no-badge');
|
||||
}
|
||||
}
|
||||
|
||||
// Add nav
|
||||
before(body, navEl);
|
||||
before(navAppendToTarget, navEl);
|
||||
|
||||
if (config.themeColor) {
|
||||
$.head.innerHTML += theme(config.themeColor);
|
||||
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docsify",
|
||||
"version": "3.5.1",
|
||||
"version": "3.6.1",
|
||||
"description": "A magical documentation generator.",
|
||||
"author": {
|
||||
"name": "qingwei-li",
|
||||
|
||||
+2
-1
@@ -17,7 +17,8 @@ const config = merge({
|
||||
autoHeader: false,
|
||||
executeScript: null,
|
||||
noEmoji: false,
|
||||
ga: ''
|
||||
ga: '',
|
||||
mergeNavbar: false
|
||||
}, window.$docsify)
|
||||
|
||||
const script = document.currentScript ||
|
||||
|
||||
@@ -7,17 +7,22 @@ const title = dom.$.title
|
||||
* Toggle button
|
||||
*/
|
||||
export function btn (el) {
|
||||
const toggle = () => dom.body.classList.toggle('close')
|
||||
const toggle = _ => dom.body.classList.toggle('close')
|
||||
|
||||
el = dom.getNode(el)
|
||||
dom.on(el, 'click', toggle)
|
||||
dom.on(el, 'click', e => {
|
||||
e.stopPropagation()
|
||||
toggle()
|
||||
})
|
||||
|
||||
const sidebar = dom.getNode('.sidebar')
|
||||
|
||||
dom.on(sidebar, 'click', () => {
|
||||
isMobile && toggle()
|
||||
setTimeout(() => getAndActive(sidebar, true, true), 0)
|
||||
})
|
||||
isMobile && dom.on(dom.body, 'click', _ =>
|
||||
dom.body.classList.contains('close') && toggle()
|
||||
)
|
||||
dom.on(sidebar, 'click', _ =>
|
||||
setTimeout((_ => getAndActive(sidebar, true, true), 0))
|
||||
)
|
||||
}
|
||||
|
||||
export function sticky () {
|
||||
|
||||
@@ -82,7 +82,7 @@ renderer.code = function (code, lang = '') {
|
||||
renderer.link = function (href, title, text) {
|
||||
let blank = ''
|
||||
if (!/:|(\/{2})/.test(href)) {
|
||||
href = toURL(href)
|
||||
href = toURL(href, null, currentPath)
|
||||
} else {
|
||||
blank = ' target="_blank"'
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { markdown, sidebar, subSidebar, cover } from './compiler'
|
||||
import { callHook } from '../init/lifecycle'
|
||||
import { getBasePath, getPath, isAbsolutePath } from '../route/util'
|
||||
import { isPrimitive } from '../util/core'
|
||||
import { isMobile } from '../util/env'
|
||||
|
||||
function executeScript () {
|
||||
const script = dom.findAll('.markdown-section>script')
|
||||
@@ -153,12 +154,8 @@ export function initRender (vm) {
|
||||
|
||||
let el = dom.find(id)
|
||||
let html = ''
|
||||
let navAppendToTarget = dom.body
|
||||
|
||||
navEl.classList.add('app-nav')
|
||||
|
||||
if (!config.repo) {
|
||||
navEl.classList.add('no-badge')
|
||||
}
|
||||
if (!el) {
|
||||
el = dom.create(id)
|
||||
dom.appendTo(dom.body, el)
|
||||
@@ -173,8 +170,19 @@ export function initRender (vm) {
|
||||
html += tpl.main(config)
|
||||
// Render main app
|
||||
vm._renderTo(el, html, true)
|
||||
|
||||
if (config.mergeNavbar && isMobile) {
|
||||
navAppendToTarget = dom.find('.sidebar')
|
||||
} else {
|
||||
navEl.classList.add('app-nav')
|
||||
|
||||
if (!config.repo) {
|
||||
navEl.classList.add('no-badge')
|
||||
}
|
||||
}
|
||||
|
||||
// Add nav
|
||||
dom.before(dom.body, navEl)
|
||||
dom.before(navAppendToTarget, navEl)
|
||||
|
||||
if (config.themeColor) {
|
||||
dom.$.head.innerHTML += tpl.theme(config.themeColor)
|
||||
|
||||
@@ -64,13 +64,17 @@ export function parse (path = window.location.href) {
|
||||
* to URL
|
||||
* @param {string} path
|
||||
* @param {object} qs query params
|
||||
* @param {string} currentRoute optional current route
|
||||
*/
|
||||
export function toURL (path, params) {
|
||||
export function toURL (path, params, currentRoute) {
|
||||
const local = currentRoute && path[0] === '#'
|
||||
const route = parse(replaceSlug(path))
|
||||
|
||||
route.query = merge({}, route.query, params)
|
||||
path = route.path + stringifyQuery(route.query)
|
||||
path = path.replace(/\.md(\?)|\.md$/, '$1')
|
||||
|
||||
if (local) path = currentRoute + path
|
||||
|
||||
return cleanPath('#/' + path)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
body:not(.ready) {
|
||||
overflow: hidden;
|
||||
|
||||
[data-cloak], nav {
|
||||
[data-cloak], .app-nav {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ kbd {
|
||||
}
|
||||
|
||||
/* navbar */
|
||||
nav.app-nav {
|
||||
.app-nav {
|
||||
left: 0;
|
||||
margin: 25px 60px 0 0;
|
||||
position: absolute;
|
||||
@@ -238,6 +238,11 @@ main {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.app-nav {
|
||||
display: block;
|
||||
position: static;
|
||||
}
|
||||
}
|
||||
|
||||
ul {
|
||||
@@ -325,7 +330,7 @@ body.sticky {
|
||||
.markdown-section {
|
||||
margin: 0 auto;
|
||||
max-width: 800px;
|
||||
padding: 20px 15px 40px 15px;
|
||||
padding: 30px 15px 40px 15px;
|
||||
position: relative;
|
||||
|
||||
> * {
|
||||
@@ -430,7 +435,7 @@ body.close {
|
||||
display: none;
|
||||
}
|
||||
|
||||
nav {
|
||||
.app-nav {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@@ -440,11 +445,11 @@ body.close {
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
nav {
|
||||
.app-nav {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
nav li ul {
|
||||
.app-nav li ul {
|
||||
top: 30px;
|
||||
}
|
||||
|
||||
@@ -465,7 +470,7 @@ body.close {
|
||||
transition: transform 250ms ease;
|
||||
}
|
||||
|
||||
nav, .github-corner {
|
||||
.app-nav, .github-corner {
|
||||
transition: transform 250ms ease-out;
|
||||
}
|
||||
|
||||
@@ -489,7 +494,7 @@ body.close {
|
||||
transform: translateX($sidebar-width);
|
||||
}
|
||||
|
||||
nav, .github-corner {
|
||||
.app-nav, .github-corner {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user