Compare commits

...
15 Commits
Author SHA1 Message Date
qingwei.li ab34cc97f9 -> v1.1.5 2016-12-18 10:50:37 +08:00
qingwei.li 3fbcd876ae bump 1.1.5 2016-12-18 10:50:02 +08:00
qingwei.li 3af5ca5cd4 Correct calculation of whether the mobile browser 2016-12-18 10:49:21 +08:00
qingwei.li 74ee0cf6bc Add table style 2016-12-18 10:37:34 +08:00
qingwei.li 46dd542b48 -> v1.1.4 2016-12-17 16:08:45 +08:00
qingwei.li cc7bdf5df2 bump 1.1.4 2016-12-17 15:56:55 +08:00
qingwei.li 9a1db6ed43 Fix chinese auchor link 2016-12-17 15:56:01 +08:00
qingwei.li 9d30ac7435 -> v1.1.3 2016-12-17 15:38:59 +08:00
qingwei.li f8a68b87c7 bump 1.1.3 2016-12-17 15:38:00 +08:00
qingwei.li 7dc47cc4d4 Optimize progress bar again 2016-12-17 15:37:32 +08:00
qingwei.li 7d995d8362 Update readme 2016-12-17 15:25:03 +08:00
qingwei.li 1fdfaf0b6b -> v1.1.2 2016-12-17 15:18:04 +08:00
qingwei.li fe33e2d506 bump 1.1.2 2016-12-17 15:17:20 +08:00
qingwei.li 6463dd3bae Optimize progress bar again 2016-12-17 15:14:52 +08:00
qingwei.li 299c31dff9 Fix auto2top in mobile 2016-12-17 15:08:44 +08:00
13 changed files with 119 additions and 44 deletions
+21
View File
@@ -1,3 +1,24 @@
## 1.1.5
### Features
- Add table style
### Bug fixes
- Not fixed position of hte navbar in the mobile browser
- Correct calculation of whether the mobile browser
## 1.1.4
### Bug fixes
- Fixed chinese auchor link
## 1.1.3
### Bug fixes
- Optimize progress bar again
## 1.1.2
### Bug fixes
- fix failed `auto2top` in mobile
## 1.1.1
### Bug fixes
- Optimize progress bar
+6 -2
View File
@@ -25,7 +25,9 @@ Create a `404.html` and `README.md` into `/docs`.
<meta charset="UTF-8">
<link rel="stylesheet" href="//unpkg.com/docsify/themes/vue.css">
</head>
<body></body>
<body>
<div id="app"></div>
</body>
<script src="//unpkg.com/docsify"></script>
</html>
```
@@ -41,7 +43,9 @@ index.html
<meta charset="UTF-8">
<link rel="stylesheet" href="//unpkg.com/docsify/themes/vue.css">
</head>
<body></body>
<body>
<div id="app"></div>
</body>
<script src="//unpkg.com/docsify" data-router></script>
</html>
```
+27 -17
View File
@@ -105,12 +105,16 @@ function getRoute () {
return route
}
function isMobile () {
return document.body.clientWidth <= 600
}
/**
* Active sidebar when scroll
* @link https://buble.surge.sh/
*/
function scrollActiveSidebar () {
if (/mobile/i.test(navigator.userAgent)) { return }
if (isMobile()) { return }
var anchors = document.querySelectorAll('.anchor');
var nav = {};
@@ -154,7 +158,7 @@ function scrollActiveSidebar () {
function scrollIntoView () {
var id = window.location.hash.match(/#[^#\/]+$/g);
if (!id || !id.length) { return }
var section = document.querySelector(id[0]);
var section = document.querySelector(decodeURIComponent(id[0]));
if (section) { section.scrollIntoView(); }
}
@@ -198,8 +202,11 @@ function bindToggle (dom) {
}
var cacheContentDOM;
function scroll2Top (dom) {
cacheContentDOM = cacheContentDOM || document.querySelector(dom);
function scroll2Top () {
if (!cacheContentDOM) {
var dom = isMobile() ? 'body' : 'section.content';
cacheContentDOM = document.querySelector(dom);
}
cacheContentDOM.scrollTop = 0;
}
@@ -2361,14 +2368,16 @@ var renderer = new marked.Renderer();
* @link https://github.com/chjj/marked#overriding-renderer-methods
*/
renderer.heading = function (text, level) {
var slug = text.toLowerCase().replace(/<(?:.|\n)*?>/gm, '').replace(/[^\w|\u4e00-\u9fa5]+/g, '-');
var slug = text.toLowerCase()
.replace(/<(?:.|\n)*?>/gm, '')
.replace(/[^\w|\u4e00-\u9fa5]+/g, '-');
var route = '';
if (OPTIONS$1.router) {
route = "#/" + (getRoute());
}
toc.push({ level: level, slug: (route + "#" + slug), title: text });
toc.push({ level: level, slug: (route + "#" + (encodeURIComponent(slug))), title: text });
return ("<h" + level + " id=\"" + slug + "\"><a href=\"" + route + "#" + slug + "\" class=\"anchor\"></a>" + text + "</h" + level + ">")
};
@@ -2412,15 +2421,15 @@ function renderArticle (content) {
renderSidebar.rendered = false;
renderNavbar.rendered = false;
if (OPTIONS$1.auto2top) { scroll2Top('section.content'); }
if (OPTIONS$1.auto2top) { scroll2Top(); }
}
/**
* navbar
*/
function renderNavbar (content) {
if (CACHE['navbar'] && CACHE['navbar'] === content) { return }
CACHE['navbar'] = content;
if (CACHE.navbar && CACHE.navbar === content) { return }
CACHE.navbar = content;
renderNavbar.rendered = true;
if (content) { renderTo('nav', marked(content)); }
@@ -2443,8 +2452,8 @@ function renderSidebar (content) {
}
renderSidebar.rendered = true;
if (CACHE['sidebar'] && CACHE['sidebar'] === content) { return }
CACHE['sidebar'] = content;
if (CACHE.sidebar && CACHE.sidebar === content) { return }
CACHE.sidebar = content;
renderTo('aside.sidebar', content);
if (isToc) { scrollActiveSidebar(); }
toc = [];
@@ -2460,21 +2469,22 @@ function renderLoading (ref) {
var num = Math.floor(loaded / total * 100);
if (!CACHE['loading']) {
if (!CACHE.loading) {
var div = document.createElement('div');
div.classList.add('progress');
document.body.appendChild(div);
CACHE['loading'] = div;
CACHE.loading = div;
}
CACHE['loading'].style.opacity = 1;
CACHE['loading'].style.width = num + '%';
CACHE.loading.style.opacity = 1;
CACHE.loading.style.width = num >= 95 ? '100%' : num + '%';
if (num >= 95) {
clearTimeout(renderLoading.cacheTImeout);
renderLoading.cacheTImeout = setTimeout(function (_) {
CACHE['loading'].style.opacity = 0;
CACHE['loading'].style.width = '0%';
CACHE.loading.style.opacity = 0;
CACHE.loading.style.width = '0%';
}, 200);
}
}
+2 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "docsify",
"version": "1.1.1",
"version": "1.1.5",
"description": "A magical documentation generator.",
"main": "lib/docsify.js",
"files": [
+8 -4
View File
@@ -1,10 +1,11 @@
import { isMobile } from './util'
/**
* Active sidebar when scroll
* @link https://buble.surge.sh/
*/
export function scrollActiveSidebar () {
if (/mobile/i.test(navigator.userAgent)) return
if (isMobile()) return
const anchors = document.querySelectorAll('.anchor')
const nav = {}
@@ -48,7 +49,7 @@ export function scrollActiveSidebar () {
export function scrollIntoView () {
const id = window.location.hash.match(/#[^#\/]+$/g)
if (!id || !id.length) return
const section = document.querySelector(id[0])
const section = document.querySelector(decodeURIComponent(id[0]))
if (section) section.scrollIntoView()
}
@@ -92,7 +93,10 @@ export function bindToggle (dom) {
}
let cacheContentDOM
export function scroll2Top (dom) {
cacheContentDOM = cacheContentDOM || document.querySelector(dom)
export function scroll2Top () {
if (!cacheContentDOM) {
const dom = isMobile() ? 'body' : 'section.content'
cacheContentDOM = document.querySelector(dom)
}
cacheContentDOM.scrollTop = 0
}
+16 -13
View File
@@ -21,14 +21,16 @@ const renderer = new marked.Renderer()
* @link https://github.com/chjj/marked#overriding-renderer-methods
*/
renderer.heading = function (text, level) {
const slug = text.toLowerCase().replace(/<(?:.|\n)*?>/gm, '').replace(/[^\w|\u4e00-\u9fa5]+/g, '-')
const slug = text.toLowerCase()
.replace(/<(?:.|\n)*?>/gm, '')
.replace(/[^\w|\u4e00-\u9fa5]+/g, '-')
let route = ''
if (OPTIONS.router) {
route = `#/${getRoute()}`
}
toc.push({ level, slug: `${route}#${slug}`, title: text })
toc.push({ level, slug: `${route}#${encodeURIComponent(slug)}`, title: text })
return `<h${level} id="${slug}"><a href="${route}#${slug}" class="anchor"></a>${text}</h${level}>`
}
@@ -70,15 +72,15 @@ export function renderArticle (content) {
renderSidebar.rendered = false
renderNavbar.rendered = false
if (OPTIONS.auto2top) scroll2Top('section.content')
if (OPTIONS.auto2top) scroll2Top()
}
/**
* navbar
*/
export function renderNavbar (content) {
if (CACHE['navbar'] && CACHE['navbar'] === content) return
CACHE['navbar'] = content
if (CACHE.navbar && CACHE.navbar === content) return
CACHE.navbar = content
renderNavbar.rendered = true
if (content) renderTo('nav', marked(content))
@@ -101,8 +103,8 @@ export function renderSidebar (content) {
}
renderSidebar.rendered = true
if (CACHE['sidebar'] && CACHE['sidebar'] === content) return
CACHE['sidebar'] = content
if (CACHE.sidebar && CACHE.sidebar === content) return
CACHE.sidebar = content
renderTo('aside.sidebar', content)
if (isToc) scrollActiveSidebar()
toc = []
@@ -115,21 +117,22 @@ export function renderSidebar (content) {
export function renderLoading ({ loaded, total }) {
const num = Math.floor(loaded / total * 100)
if (!CACHE['loading']) {
if (!CACHE.loading) {
const div = document.createElement('div')
div.classList.add('progress')
document.body.appendChild(div)
CACHE['loading'] = div
CACHE.loading = div
}
CACHE['loading'].style.opacity = 1
CACHE['loading'].style.width = num + '%'
CACHE.loading.style.opacity = 1
CACHE.loading.style.width = num >= 95 ? '100%' : num + '%'
if (num >= 95) {
clearTimeout(renderLoading.cacheTImeout)
renderLoading.cacheTImeout = setTimeout(_ => {
CACHE['loading'].style.opacity = 0
CACHE['loading'].style.width = '0%'
CACHE.loading.style.opacity = 0
CACHE.loading.style.width = '0%'
}, 200)
}
}
+29 -1
View File
@@ -235,6 +235,33 @@ main {
}
}
.markdown-section table {
display: block;
width: 100%;
overflow: auto;
border-spacing: 0;
border-collapse: collapse;
}
.markdown-section th {
font-weight: bold;
padding: 6px 13px;
border: 1px solid #ddd;
}
.markdown-section td {
padding: 6px 13px;
border: 1px solid #ddd;
}
.markdown-section tr {
background-color: #fff;
border-top: 1px solid #ccc;
&:nth-child(2n) {
background-color: #f8f8f8;
}
}
body.close {
.sidebar {
transform: translateX(-$sidebar-width);
@@ -246,11 +273,12 @@ body.close {
}
@media (max-width: 600px) {
nav, .github-corner, .sidebar-toggle, .sidebar {
.github-corner, .sidebar-toggle, .sidebar {
position: fixed;
}
nav {
position: static;
margin-top: 16px;
}
+1 -1
View File
@@ -277,7 +277,7 @@ code .token {
pre::after {
color: #ccc;
content: attr(data-lang);
font-size: 0.75em;
font-size: 0.6em;
font-weight: 600;
height: 15px;
line-height: 15px;
+5
View File
@@ -95,3 +95,8 @@ export function getRoute () {
return route
}
export function isMobile () {
return document.body.clientWidth <= 600
}