mirror of
https://github.com/wahyd4/docsify.git
synced 2026-08-10 05:48:18 +10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58789bfec7 | ||
|
|
e7e519bad2 | ||
|
|
f7111b5903 | ||
|
|
42b2dba589 | ||
|
|
2a1157a706 | ||
|
|
3394ebb9a5 | ||
|
|
b4fc6a9d72 | ||
|
|
feb4b89461 | ||
|
|
83d7862505 | ||
|
|
75686f1624 | ||
|
|
780c1e580e | ||
|
|
35dd2e16fa |
@@ -1,4 +1,18 @@
|
||||
|
||||
3.0.5 / 2017-02-21
|
||||
==================
|
||||
|
||||
* feat(pwa): add sw.js
|
||||
* fix(layout.css): loading style
|
||||
* fix(event): highlight sidebar when clicked, fixed #86
|
||||
* fix(gen-tree): cache toc list, fixed #88
|
||||
|
||||
3.0.4 / 2017-02-20
|
||||
==================
|
||||
|
||||
* fix(render): execute script
|
||||
* fix(render): disable rendering sub list when loadSidebar is false
|
||||
|
||||
3.0.3 / 2017-02-19
|
||||
==================
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
- [CLI](https://github.com/QingWei-Li/docsify-cli)
|
||||
|
||||
## Features
|
||||
- Not build static html files
|
||||
|
||||
- No statically built html files
|
||||
- Simple and lightweight (~14kB gzipped)
|
||||
- Smart full-text search plugin
|
||||
- Multiple themes
|
||||
@@ -29,9 +30,9 @@
|
||||
## Quick start
|
||||
Create a `index.html`.
|
||||
|
||||
index.html
|
||||
|
||||
```html
|
||||
<!-- index.html -->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@@ -47,10 +48,10 @@ index.html
|
||||
|
||||
## Browser Support
|
||||
|
||||
Modern browsers and Internet Explorer 9+.
|
||||
Modern browsers and Internet Explorer 10+.
|
||||
|
||||
## Showcase
|
||||
These open-source projects are using docsify to generate their sites. Pull requests welcome : )
|
||||
These open-source projects are using docsify to generate their sites. Pull requests welcome :blush:
|
||||
|
||||
- [Snipaste](https://docs.snipaste.com/) - Snip & Paste
|
||||
- [puck](https://puck.zz173.com/) - A small & magical php framework.
|
||||
@@ -69,7 +70,7 @@ These open-source projects are using docsify to generate their sites. Pull reque
|
||||
- Create your feature branch: `git checkout -b my-new-feature`
|
||||
- Commit your changes: `git commit -am 'Add some feature'`
|
||||
- Push to the branch: `git push origin my-new-feature`
|
||||
- Submit a pull request :D
|
||||
- Submit a pull request
|
||||
|
||||
|
||||
## Development
|
||||
|
||||
+4
-4
@@ -4,13 +4,13 @@
|
||||
|
||||
## What is it
|
||||
|
||||
docsify generates your documentation website on the fly. Unlike GitBook, it does not generate static html files. It smartly loads and parses your Markdown files and displays them in website. All you need to do is create an `index.html` to start and [deploy it on GitHub Pages](/deploy).
|
||||
docsify generates your documentation website on the fly. Unlike GitBook, it does not generate static html files. Instead, it smartly loads and parses your Markdown files and displays them as website. All you need to do is create an `index.html` to start and [deploy it on GitHub Pages](/deploy).
|
||||
|
||||
See the [Quick start](/quickstart) for more details.
|
||||
|
||||
## Features
|
||||
|
||||
- Not build static html files
|
||||
- No statically built html files
|
||||
- Simple and lightweight (~14kB gzipped)
|
||||
- Smart full-text search plugin
|
||||
- Multiple themes
|
||||
@@ -19,9 +19,9 @@ See the [Quick start](/quickstart) for more details.
|
||||
|
||||
## Examples
|
||||
|
||||
Check out the [Showcase](https://github.com/QingWei-Li/docsify/#showcase) to see use the docsify generated website.
|
||||
Check out the [Showcase](https://github.com/QingWei-Li/docsify/#showcase) to docsify in use.
|
||||
|
||||
## Donate
|
||||
|
||||
If you think docsify is helpful to you or that my work is valuable. I am happy if you can help me [buy a cup of coffee](https://github.com/QingWei-Li/donate). :heart:
|
||||
Please consider donating if you think docsify is helpful to you or that my work is valuable. I am happy if you can help me [buy a cup of coffee](https://github.com/QingWei-Li/donate). :heart:
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
> A magical documentation site generator.
|
||||
|
||||
- Simple and lightweight (~14kB gzipped)
|
||||
- Not build static html files
|
||||
- No statically built html files
|
||||
- Multiple themes
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -9,12 +9,12 @@
|
||||
- [Themes](/themes)
|
||||
- [Using plugins](/plugins)
|
||||
- [Markdown configuration](/markdown)
|
||||
- [Lanuage highlight](/language-highlight)
|
||||
- [Lanuage highlighting](/language-highlight)
|
||||
|
||||
- Guide
|
||||
- [Deploy](/deploy)
|
||||
- [Doc helper](/helpers)
|
||||
- [Compatible Vue](/vue)
|
||||
- [Helpers](/helpers)
|
||||
- [Vue compatibility](/vue)
|
||||
- [CDN](/cdn)
|
||||
|
||||
- [Changelog](/changelog)
|
||||
+13
-13
@@ -1,15 +1,14 @@
|
||||
# Cover
|
||||
|
||||
Activate the cover feature by setting `coverpage`. The detail in [Configuration#coverpage](configuration#coverpage).
|
||||
Activate the cover feature by setting `coverpage` to **true**. Details are available in the [coverpage configuration paragraph](configuration#coverpage).
|
||||
|
||||
## Basic usage
|
||||
|
||||
Set `coverpage` to **true**, and create a `_coverpage.md`. You can see the effect in current website.
|
||||
|
||||
|
||||
*index.html*
|
||||
Set `coverpage` to **true**, and create a `_coverpage.md`:
|
||||
|
||||
```html
|
||||
<!-- index.html -->
|
||||
|
||||
<script>
|
||||
window.$docsify = {
|
||||
coverpage: true
|
||||
@@ -18,33 +17,34 @@ Set `coverpage` to **true**, and create a `_coverpage.md`. You can see the effec
|
||||
<script src="//unpkg.com/docsify"></script>
|
||||
```
|
||||
|
||||
*_coverpage.md*
|
||||
|
||||
```markdown
|
||||
<!-- _coverpage.md -->
|
||||
|
||||

|
||||
|
||||
# docsify
|
||||
# docsify <small>3.0</small>
|
||||
|
||||
> A magical documentation site generator.
|
||||
|
||||
- Simple and lightweight (~12kb gzipped)
|
||||
- Simple and lightweight (~14kB gzipped)
|
||||
- No statically built html files
|
||||
- Multiple themes
|
||||
- Not build static html files
|
||||
|
||||
|
||||
[GitHub](https://github.com/QingWei-Li/docsify/)
|
||||
[Get Started](#quick-start)
|
||||
[Get Started](#docsify)
|
||||
```
|
||||
|
||||
!> A document site can have only one cover page.
|
||||
|
||||
## Custom background
|
||||
|
||||
The background color is generated randomly by default. You can customize the background color or image.
|
||||
|
||||
*_coverpage.md*
|
||||
The background color is generated randomly by default. You can customize the background color or image:
|
||||
|
||||
```markdown
|
||||
<!-- _coverpage.md -->
|
||||
|
||||
# docsify
|
||||
|
||||
[GitHub](https://github.com/QingWei-Li/docsify/)
|
||||
|
||||
+16
-11
@@ -1,10 +1,12 @@
|
||||
# Custom navbar
|
||||
|
||||
You can create navbar in HTML file. But note that the link begins with `#/`.
|
||||
## HTML
|
||||
|
||||
*index.html*
|
||||
If you need custom navigation, you can create a HTML-based navigation bar (but note that documentation links begin with `#/`).
|
||||
|
||||
```html
|
||||
<!-- index.html -->
|
||||
|
||||
<body>
|
||||
<nav>
|
||||
<a href="#/">EN</a>
|
||||
@@ -14,14 +16,13 @@ You can create navbar in HTML file. But note that the link begins with `#/`.
|
||||
</body>
|
||||
```
|
||||
|
||||
## Writing by Markdown
|
||||
|
||||
You can custom navbar by Markdown file. Set the `loadNavbar` to **true** and create a `_navbar.md`. The detail in [Configuration#load-navbar](configuration#load-navbar).
|
||||
|
||||
*index.html*
|
||||
## Markdown
|
||||
|
||||
Alternatively, you can create a custom markdown-based navigation file by setting `loadNavbar` to **true** and creating `_navbar.md`. Details are available in the [load-navbar configuration paragraph](configuration#load-navbar).
|
||||
|
||||
```html
|
||||
<!-- index.html -->
|
||||
|
||||
<script>
|
||||
window.$docsify = {
|
||||
loadNavbar: true
|
||||
@@ -30,21 +31,25 @@ You can custom navbar by Markdown file. Set the `loadNavbar` to **true** and cre
|
||||
<script src="//unpkg.com/docsify"></script>
|
||||
```
|
||||
|
||||
*_navbar.md*
|
||||
|
||||
|
||||
```markdown
|
||||
<!-- _navbar.md -->
|
||||
|
||||
- [En](/)
|
||||
- [chinese](/zh-cn/)
|
||||
```
|
||||
|
||||
`_navbar.md` is loaded from each level directory. If this directory doesn't have `_navbar.md`, it will fallback to parent directory. For example, the current path is `/guide/quick-start`, the `_navbar.md` will be loaded from `/guide/_navbar.md`.
|
||||
!> You need to create a `.nojekyll` in `./docs` to prevent GitHub Pages from ignoring files that begin with an underscore.
|
||||
|
||||
`_navbar.md` is loaded from each level directory. If the current directory doesn't have `_navbar.md`, it will fall back to the parent directory. If, for example, the current path is `/guide/quick-start`, the `_navbar.md` will be loaded from `/guide/_navbar.md`.
|
||||
|
||||
## Nesting
|
||||
|
||||
You can create sub-lists by indenting items that are under a certain parent.
|
||||
|
||||
```markdown
|
||||
<!-- _navbar.md -->
|
||||
|
||||
- Getting started
|
||||
- [Quick start](/quickstart)
|
||||
- [Writing more pages](/more-pages)
|
||||
@@ -59,7 +64,7 @@ You can create sub-lists by indenting items that are under a certain parent.
|
||||
- [Lanuage highlight](/language-highlight)
|
||||
```
|
||||
|
||||
Example.
|
||||
renders as
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -32,6 +32,10 @@
|
||||
'/changelog': 'https://raw.githubusercontent.com/QingWei-Li/docsify/master/CHANGELOG'
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof navigator.serviceWorker !== 'undefined') {
|
||||
navigator.serviceWorker.register('sw.js')
|
||||
}
|
||||
</script>
|
||||
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
|
||||
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
|
||||
|
||||
+14
-10
@@ -1,10 +1,9 @@
|
||||
# More pages
|
||||
|
||||
If you need more pages multi-level routing site. It is easy to achieve in docsify. A simple example: If you create a `guide.md`, then get the route is `/#/guide`.
|
||||
If you need more pages, you can simply create more markdown files in your docsify directory. If you create a file named `guide.md`, then it is accessible via `/#/guide`.
|
||||
|
||||
For example, the directory structure is as follows:
|
||||
|
||||
|
||||
```text
|
||||
-| docs/
|
||||
-| README.md
|
||||
@@ -26,11 +25,13 @@ docs/zh-cn/guide.md => http://domain.com/zh-cn/guide
|
||||
|
||||
## Custom sidebar
|
||||
|
||||
By default, the TOC in sidebar is automatically generated based on Markdown file. You can create a Table of Contents page to list down pages in your site.
|
||||
By default, the table of contents in the sidebar is automatically generated based on your markdown files. If you need a custom sidebar, then you can create your own `_sidebar.md` (see [this documentation's sidebar](https://github.com/QingWei-Li/docsify/blob/master/docs/_sidebar.md) for an example):
|
||||
|
||||
First, you need to set `loadSidebar` to **true**. The detail in [Configuration#load-sidebar](configuration#load-sidebar).
|
||||
First, you need to set `loadSidebar` to **true**. Details are available in the [configuration paragraph](configuration#load-sidebar).
|
||||
|
||||
```html
|
||||
<!-- index.html -->
|
||||
|
||||
<script>
|
||||
window.$docsify = {
|
||||
loadSidebar: true
|
||||
@@ -39,22 +40,26 @@ First, you need to set `loadSidebar` to **true**. The detail in [Configuration#l
|
||||
<script src="//unpkg.com/docsify"></script>
|
||||
```
|
||||
|
||||
Create the `_sidebar.md`
|
||||
Create the `_sidebar.md`:
|
||||
|
||||
```markdown
|
||||
<!-- docs/_sidebar.md -->
|
||||
|
||||
- [Home](/)
|
||||
- [Guide](/guide)
|
||||
```
|
||||
|
||||
!> Need create a `.nojekyll` in `./docs` to prevent GitHub Pages from ignoring files that begin with an underscore.
|
||||
!> You need to create a `.nojekyll` in `./docs` to prevent GitHub Pages from ignoring files that begin with an underscore.
|
||||
|
||||
`_sidebar.md` is loaded from each level directory. If this directory doesn't have `_sidebar.md`, it will fallback to parent directory. For example, the current path is `/guide/quick-start`, the `_sidebar.md` will be loaded from `/guide/_sidebar.md`.
|
||||
`_sidebar.md` is loaded from each level directory. If the current directory doesn't have `_sidebar.md`, it will fall back to the parent directory. If, for example, the current path is `/guide/quick-start`, the `_sidebar.md` will be loaded from `/guide/_sidebar.md`.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
Custom sidebar can also be automatically generate TOC by setting `subMaxLevel`. The detail in [Configuration#sub-max-level](configuration#sub-max-level).
|
||||
A custom sidebar can also automatically generate a table of contents by setting a `subMaxLevel`. Details are available in the [max-level configuration paragraph](configuration#sub-max-level).
|
||||
|
||||
```html
|
||||
<!-- index.html -->
|
||||
|
||||
<script>
|
||||
window.$docsify = {
|
||||
loadSidebar: true,
|
||||
@@ -62,5 +67,4 @@ Custom sidebar can also be automatically generate TOC by setting `subMaxLevel`.
|
||||
}
|
||||
</script>
|
||||
<script src="//unpkg.com/docsify"></script>
|
||||
```
|
||||
|
||||
```
|
||||
+18
-16
@@ -1,14 +1,14 @@
|
||||
# Quick start
|
||||
|
||||
Recommended install `docsify-cli` globally, which can help us to initialize and preview the website locally.
|
||||
It is recommended to install `docsify-cli` globally, which helps initializing and previewing the website locally.
|
||||
|
||||
```bash
|
||||
npm i docsify-cli -g
|
||||
```
|
||||
|
||||
## initialize
|
||||
## Initialize
|
||||
|
||||
If you want to write the documentation in `./docs` directory, you can use the `init` command.
|
||||
If you want to write the documentation in the `./docs` directory, you can use the `init` command.
|
||||
|
||||
```bash
|
||||
docsify init ./docs
|
||||
@@ -21,28 +21,28 @@ After the init is complete, you can see the file list in the docs directory.
|
||||
|
||||
- `index.html` as the entry file
|
||||
- `README.md` as the home page
|
||||
- `.nojekyll` can prevent GitHub Pages from ignoring files that begin with an underscore
|
||||
- `.nojekyll` prevents GitHub Pages from ignoring files that begin with an underscore
|
||||
|
||||
You can easily update the documentation in `docs/README.md`, of course you can add [more pages](more-pages).
|
||||
|
||||
## Preview your site
|
||||
|
||||
Run the local server via `docsify serve`. You can preview your site in browser via http://localhost:3000.
|
||||
Run the local server with `docsify serve`. You can preview your site in your browser on `http://localhost:3000`.
|
||||
|
||||
|
||||
```bash
|
||||
docsify serve docs
|
||||
```
|
||||
|
||||
?> More usages of reference [docsify-cli documentation](https://github.com/QingWei-Li/docsify-cli).
|
||||
?> For more use cases of `docsify-cli`, head over to the [docsify-cli documentation](https://github.com/QingWei-Li/docsify-cli).
|
||||
|
||||
## Manually
|
||||
## Manual initialization
|
||||
|
||||
If you don't like npm or feel the trouble to install the tool. What we need is an `index.html`.
|
||||
|
||||
*index.html*
|
||||
If you don't like npm or have trouble installing the tool, you can manually create `index.html`:
|
||||
|
||||
```html
|
||||
<!-- index.html -->
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@@ -56,25 +56,27 @@ If you don't like npm or feel the trouble to install the tool. What we need is a
|
||||
</html>
|
||||
```
|
||||
|
||||
If your system has Python, you can easily to run a static server to preview your site.
|
||||
If you installed python on your system, you can easily use it to run a static server to preview your site.
|
||||
|
||||
```bash
|
||||
cd docs && python -m SimpleHTTPServer 3000
|
||||
```
|
||||
|
||||
## Loading tip
|
||||
## Loading dialog
|
||||
|
||||
Show `Loading...` Before starting rendering. You can customize the content.
|
||||
If you want, you can show a loading dialog before docsify starts to render your documentation:
|
||||
|
||||
*index.html*
|
||||
```html
|
||||
<!-- index.html -->
|
||||
|
||||
<div id="app">Please wait...</div>
|
||||
```
|
||||
|
||||
You should set the `data-app` attribute if you changed `el`.
|
||||
You should set the `data-app` attribute if you changed `el`:
|
||||
|
||||
*index.html*
|
||||
```html
|
||||
<!-- index.html -->
|
||||
|
||||
<div data-app id="main">Please wait...</div>
|
||||
|
||||
<script>
|
||||
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/* ===========================================================
|
||||
* docsify sw.js
|
||||
* ===========================================================
|
||||
* Copyright 2016 @huxpro
|
||||
* Licensed under Apache 2.0
|
||||
* Register service worker.
|
||||
* ========================================================== */
|
||||
|
||||
const RUNTIME = 'docsify';
|
||||
const HOSTNAME_WHITELIST = [
|
||||
self.location.hostname,
|
||||
'unpkg.com',
|
||||
'fonts.gstatic.com',
|
||||
'fonts.googleapis.com'
|
||||
]
|
||||
|
||||
// The Util Function to hack URLs of intercepted requests
|
||||
const getFixedUrl = (req) => {
|
||||
var now = Date.now();
|
||||
url = new URL(req.url)
|
||||
|
||||
// 1. fixed http URL
|
||||
// Just keep syncing with location.protocol
|
||||
// fetch(httpURL) belongs to active mixed content.
|
||||
// And fetch(httpRequest) is not supported yet.
|
||||
url.protocol = self.location.protocol
|
||||
|
||||
// 2. add query for caching-busting.
|
||||
// Github Pages served with Cache-Control: max-age=600
|
||||
// max-age on mutable content is error-prone, with SW life of bugs can even extend.
|
||||
// Until cache mode of Fetch API landed, we have to workaround cache-busting with query string.
|
||||
// Cache-Control-Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=453190
|
||||
url.search += (url.search ? '&' : '?') + 'cache-bust=' + now;
|
||||
return url.href
|
||||
}
|
||||
|
||||
/**
|
||||
* @Lifecycle Activate
|
||||
* New one activated when old isnt being used.
|
||||
*
|
||||
* waitUntil(): activating ====> activated
|
||||
*/
|
||||
self.addEventListener('activate', event => {
|
||||
event.waitUntil(self.clients.claim());
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @Functional Fetch
|
||||
* All network requests are being intercepted here.
|
||||
*
|
||||
* void respondWith(Promise<Response> r);
|
||||
*/
|
||||
self.addEventListener('fetch', event => {
|
||||
// Skip some of cross-origin requests, like those for Google Analytics.
|
||||
if (HOSTNAME_WHITELIST.indexOf(new URL(event.request.url).hostname) > -1) {
|
||||
// Stale-while-revalidate
|
||||
// similar to HTTP's stale-while-revalidate: https://www.mnot.net/blog/2007/12/12/stale
|
||||
// Upgrade from Jake's to Surma's: https://gist.github.com/surma/eb441223daaedf880801ad80006389f1
|
||||
const cached = caches.match(event.request);
|
||||
const fixedUrl = getFixedUrl(event.request);
|
||||
const fetched = fetch(fixedUrl, {cache: 'no-store'});
|
||||
const fetchedCopy = fetched.then(resp => resp.clone());
|
||||
|
||||
// Call respondWith() with whatever we get first.
|
||||
// If the fetch fails (e.g disconnected), wait for the cache.
|
||||
// If there’s nothing in cache, wait for the fetch.
|
||||
// If neither yields a response, return offline pages.
|
||||
event.respondWith(
|
||||
Promise.race([fetched.catch(_ => cached), cached])
|
||||
.then(resp => resp || fetched)
|
||||
.catch(_ => {/* eat any errors */})
|
||||
);
|
||||
|
||||
// Update the cache with the version we fetched (only for ok status)
|
||||
event.waitUntil(
|
||||
Promise.all([fetchedCopy, caches.open(RUNTIME)])
|
||||
.then(([response, cache]) => response.ok && cache.put(event.request, response))
|
||||
.catch(_ => {/* eat any errors */})
|
||||
);
|
||||
}
|
||||
});
|
||||
+1
-1
@@ -76,7 +76,7 @@ You can manually initialize a Vue instance.
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
module.exports = {
|
||||
data: function () {
|
||||
return { name: 'Vue' }
|
||||
}
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
module.exports = {
|
||||
data: function () {
|
||||
return { name: 'Vue' }
|
||||
}
|
||||
|
||||
+15
-21
@@ -74,7 +74,7 @@ var config = merge({
|
||||
themeColor: '',
|
||||
nameLink: window.location.pathname,
|
||||
autoHeader: false,
|
||||
executeScript: false,
|
||||
executeScript: null,
|
||||
ga: ''
|
||||
}, window.$docsify);
|
||||
|
||||
@@ -407,14 +407,12 @@ function btn (el) {
|
||||
el = getNode(el);
|
||||
on(el, 'click', toggle);
|
||||
|
||||
if (isMobile) {
|
||||
var sidebar = getNode('.sidebar');
|
||||
var sidebar = getNode('.sidebar');
|
||||
|
||||
on(sidebar, 'click', function () {
|
||||
toggle();
|
||||
setTimeout(function () { return getAndActive(sidebar, true, true); }, 0);
|
||||
});
|
||||
}
|
||||
on(sidebar, 'click', function () {
|
||||
isMobile && toggle();
|
||||
setTimeout(function () { return getAndActive(sidebar, true, true); }, 0);
|
||||
});
|
||||
}
|
||||
|
||||
function sticky () {
|
||||
@@ -598,7 +596,6 @@ var progressbar = function (ref) {
|
||||
};
|
||||
|
||||
var cache = {};
|
||||
var RUN_VERSION = Date.now();
|
||||
|
||||
/**
|
||||
* Simple ajax get
|
||||
@@ -614,8 +611,6 @@ function get (url, hasBar) {
|
||||
xhr.addEventListener.apply(xhr, arguments);
|
||||
};
|
||||
|
||||
url += (/\?(\w+)=/g.test(url) ? '&' : '?') + "v=" + RUN_VERSION;
|
||||
|
||||
if (cache[url]) {
|
||||
return { then: function (cb) { return cb(cache[url]); }, abort: noop }
|
||||
}
|
||||
@@ -2893,8 +2888,7 @@ function genTree (toc, maxLevel) {
|
||||
|
||||
if (level > maxLevel) { return }
|
||||
if (last[len]) {
|
||||
last[len].children = last[len].children || [];
|
||||
last[len].children.push(headline);
|
||||
last[len].children = (last[len].children || []).concat(headline);
|
||||
} else {
|
||||
headlines.push(headline);
|
||||
}
|
||||
@@ -2943,7 +2937,7 @@ var markdownCompiler = marked;
|
||||
var contentBase = '';
|
||||
var currentPath = '';
|
||||
var renderer = new marked.Renderer();
|
||||
var TOC = {};
|
||||
var cacheTree = {};
|
||||
var toc = [];
|
||||
|
||||
/**
|
||||
@@ -3056,11 +3050,9 @@ function sidebar (text, level) {
|
||||
function subSidebar (el, level) {
|
||||
if (el) {
|
||||
toc[0] && toc[0].level === 1 && toc.shift();
|
||||
var tree$$1 = genTree(TOC[currentPath] || toc, level);
|
||||
var tree$$1 = cacheTree[currentPath] || genTree(toc, level);
|
||||
el.parentNode.innerHTML += tree(tree$$1, '<ul class="app-sub-sidebar">');
|
||||
}
|
||||
if (toc.length) {
|
||||
TOC[currentPath] = toc.slice();
|
||||
cacheTree[currentPath] = tree$$1;
|
||||
}
|
||||
toc = [];
|
||||
}
|
||||
@@ -3106,9 +3098,8 @@ function renderMain (html) {
|
||||
this._renderTo('.markdown-section', html);
|
||||
// Render sidebar with the TOC
|
||||
!this.config.loadSidebar && this._renderSidebar();
|
||||
// execute script
|
||||
this.config.executeScript && executeScript();
|
||||
|
||||
// execute script
|
||||
if (this.config.executeScript !== false &&
|
||||
typeof window.Vue !== 'undefined' &&
|
||||
!executeScript()) {
|
||||
@@ -3117,6 +3108,8 @@ function renderMain (html) {
|
||||
vueVM && vueVM.$destroy && vueVM.$destroy();
|
||||
window.__EXECUTE_RESULT__ = new window.Vue().$mount('#main');
|
||||
}, 0);
|
||||
} else {
|
||||
this.config.executeScript && executeScript();
|
||||
}
|
||||
|
||||
if (this.config.auto2top) {
|
||||
@@ -3135,10 +3128,11 @@ function renderMixin (proto) {
|
||||
var maxLevel = ref.maxLevel;
|
||||
var subMaxLevel = ref.subMaxLevel;
|
||||
var autoHeader = ref.autoHeader;
|
||||
var loadSidebar = ref.loadSidebar;
|
||||
|
||||
this._renderTo('.sidebar-nav', sidebar(text, maxLevel));
|
||||
var active = getAndActive('.sidebar-nav', true, true);
|
||||
subSidebar(active, subMaxLevel);
|
||||
loadSidebar && subSidebar(active, subMaxLevel);
|
||||
// bind event
|
||||
this.activeLink = active;
|
||||
scrollActiveSidebar();
|
||||
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -1 +1 @@
|
||||
this.D=this.D||{},function(){"use strict";function e(e){var n={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(e).replace(/[&<>"'\/]/g,function(e){return n[e]})}function n(){var e=[];return d.dom.findAll("a").map(function(n){var t=n.href,r=n.getAttribute("href"),i=d.route.parse(t).path;i&&e.indexOf(i)===-1&&!d.route.isAbsolutePath(r)&&e.push(i)}),e}function t(e){localStorage.setItem("docsify.search.expires",Date.now()+e),localStorage.setItem("docsify.search.index",JSON.stringify(f))}function r(e,n){void 0===n&&(n="");var t,r=window.marked.lexer(n),i=Docsify.route.toURL,o={};return r.forEach(function(n){if("heading"===n.type&&n.depth<=2)t=i(e,{id:n.text}),o[t]={slug:t,title:n.text,body:""};else{if(!t)return;o[t]?o[t].body?o[t].body+="\n"+(n.text||""):o[t].body=n.text:o[t]={slug:t,title:"",body:""}}}),o}function i(n){var t=[],r=[];Object.keys(f).forEach(function(e){r=r.concat(Object.keys(f[e]).map(function(n){return f[e][n]}))}),n=n.trim().split(/[\s\-\,\\\/]+/);for(var i=function(i){var o=r[i],a=!1,s="",c=o.title&&o.title.trim(),l=o.body&&o.body.trim(),p=o.slug||"";if(c&&l&&(n.forEach(function(n,t){var r=new RegExp(n,"gi"),i=-1,o=-1;if(i=c&&c.search(r),o=l&&l.search(r),i<0&&o<0)a=!1;else{a=!0,o<0&&(o=0);var p=0,u=0;p=o<11?0:o-10,u=0===p?70:o+n.length+60,u>l.length&&(u=l.length);var d="..."+e(l).substring(p,u).replace(r,'<em class="search-keyword">'+n+"</em>")+"...";s+=d}}),a)){var u={title:e(c),content:s,url:p};t.push(u)}},o=0;o<r.length;o++)i(o);return t}function o(e,i){d=Docsify;var o="auto"===e.paths,a=localStorage.getItem("docsify.search.expires")<Date.now();if(f=JSON.parse(localStorage.getItem("docsify.search.index")),a)f={};else if(!o)return;var s=o?n():e.paths,c=s.length,l=0;s.forEach(function(n){return f[n]?l++:void d.get(i.$getFile(n)).then(function(i){f[n]=r(n,i),c===++l&&t(e.maxAge)})})}function a(){var e="\n.sidebar {\n padding-top: 0;\n}\n\n.search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n}\n\n.search .results-panel {\n display: none;\n}\n\n.search .results-panel.show {\n display: block;\n}\n\n.search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 7px;\n line-height: 22px;\n font-size: 14px;\n}\n\n.search h2 {\n font-size: 17px;\n margin: 10px 0;\n}\n\n.search a {\n text-decoration: none;\n color: inherit;\n}\n\n.search .matching-post {\n border-bottom: 1px solid #eee;\n}\n\n.search .matching-post:last-child {\n border-bottom: 0;\n}\n\n.search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n\n.search p.empty {\n text-align: center;\n}",n=h.create("style",e);h.appendTo(h.head,n)}function s(e){var n='<input type="search" /><div class="results-panel"></div></div>',t=h.create("div",n),r=h.find("aside");h.toggleClass(t,"search"),h.before(r,t)}function c(){var e,n=h.find("div.search"),t=h.find(n,"input"),r=h.find(n,".results-panel"),o=function(e){if(!e)return r.classList.remove("show"),void(r.innerHTML="");var n=i(e),t="";n.forEach(function(e){t+='<div class="matching-post">\n <h2><a href="'+e.url+'">'+e.title+"</a></h2>\n <p>"+e.content+"</p>\n</div>"}),r.classList.add("show"),r.innerHTML=t||'<p class="empty">No Results!</p>'};h.on(n,"click",function(e){return"A"!==e.target.tagName&&e.stopPropagation()}),h.on(t,"input",function(n){clearTimeout(e),e=setTimeout(function(e){return o(n.target.value.trim())},200)})}function l(e,n){var t=h.getNode('.search input[type="search"]');if("string"==typeof e)t.placeholder=e;else{var r=Object.keys(e).find(function(e){return n.indexOf(e)>-1});t.placeholder=e[r]}}function p(e){h=Docsify.dom,a(),s(e),c()}function u(e,n){l(e.placeholder,n.route.path)}var d,h,f={},g={placeholder:"Type to search",paths:"auto",maxAge:864e5},m=function(e,n){var t=Docsify.util,r=n.config.search||g;Array.isArray(r)?g.paths=r:"object"==typeof r&&(g.paths=Array.isArray(r.paths)?r.paths:"auto",g.maxAge=t.isPrimitive(r.maxAge)?r.maxAge:g.maxAge,g.placeholder=r.placeholder||g.placeholder);var i="auto"===g.paths;e.mounted(function(e){p(g),!i&&o(g,n)}),e.doneEach(function(e){u(g,n),i&&o(g,n)})};window.$docsify.plugins=[].concat(m,window.$docsify.plugins)}();
|
||||
this.D=this.D||{},function(){"use strict";function e(e){var n={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(e).replace(/[&<>"'\/]/g,function(e){return n[e]})}function n(){var e=[];return d.dom.findAll("a").map(function(n){var t=n.href,r=n.getAttribute("href"),i=d.route.parse(t).path;i&&e.indexOf(i)===-1&&!d.route.isAbsolutePath(r)&&e.push(i)}),e}function t(e){localStorage.setItem("docsify.search.expires",Date.now()+e),localStorage.setItem("docsify.search.index",JSON.stringify(f))}function r(e,n){void 0===n&&(n="");var t,r=window.marked.lexer(n),i=Docsify.route.toURL,o={};return r.forEach(function(n){if("heading"===n.type&&n.depth<=2)t=i(e,{id:n.text}),o[t]={slug:t,title:n.text,body:""};else{if(!t)return;o[t]?o[t].body?o[t].body+="\n"+(n.text||""):o[t].body=n.text:o[t]={slug:t,title:"",body:""}}}),o}function i(n){var t=[],r=[];Object.keys(f).forEach(function(e){r=r.concat(Object.keys(f[e]).map(function(n){return f[e][n]}))}),n=n.trim().split(/[\s\-\,\\/]+/);for(var i=function(i){var o=r[i],a=!1,s="",c=o.title&&o.title.trim(),l=o.body&&o.body.trim(),p=o.slug||"";if(c&&l&&(n.forEach(function(n,t){var r=new RegExp(n,"gi"),i=-1,o=-1;if(i=c&&c.search(r),o=l&&l.search(r),i<0&&o<0)a=!1;else{a=!0,o<0&&(o=0);var p=0,u=0;p=o<11?0:o-10,u=0===p?70:o+n.length+60,u>l.length&&(u=l.length);var d="..."+e(l).substring(p,u).replace(r,'<em class="search-keyword">'+n+"</em>")+"...";s+=d}}),a)){var u={title:e(c),content:s,url:p};t.push(u)}},o=0;o<r.length;o++)i(o);return t}function o(e,i){d=Docsify;var o="auto"===e.paths,a=localStorage.getItem("docsify.search.expires")<Date.now();if(f=JSON.parse(localStorage.getItem("docsify.search.index")),a)f={};else if(!o)return;var s=o?n():e.paths,c=s.length,l=0;s.forEach(function(n){return f[n]?l++:void d.get(i.$getFile(n)).then(function(i){f[n]=r(n,i),c===++l&&t(e.maxAge)})})}function a(){var e="\n.sidebar {\n padding-top: 0;\n}\n\n.search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n}\n\n.search .results-panel {\n display: none;\n}\n\n.search .results-panel.show {\n display: block;\n}\n\n.search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 7px;\n line-height: 22px;\n font-size: 14px;\n}\n\n.search h2 {\n font-size: 17px;\n margin: 10px 0;\n}\n\n.search a {\n text-decoration: none;\n color: inherit;\n}\n\n.search .matching-post {\n border-bottom: 1px solid #eee;\n}\n\n.search .matching-post:last-child {\n border-bottom: 0;\n}\n\n.search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n\n.search p.empty {\n text-align: center;\n}",n=h.create("style",e);h.appendTo(h.head,n)}function s(e){var n='<input type="search" /><div class="results-panel"></div></div>',t=h.create("div",n),r=h.find("aside");h.toggleClass(t,"search"),h.before(r,t)}function c(){var e,n=h.find("div.search"),t=h.find(n,"input"),r=h.find(n,".results-panel"),o=function(e){if(!e)return r.classList.remove("show"),void(r.innerHTML="");var n=i(e),t="";n.forEach(function(e){t+='<div class="matching-post">\n <h2><a href="'+e.url+'">'+e.title+"</a></h2>\n <p>"+e.content+"</p>\n</div>"}),r.classList.add("show"),r.innerHTML=t||'<p class="empty">No Results!</p>'};h.on(n,"click",function(e){return"A"!==e.target.tagName&&e.stopPropagation()}),h.on(t,"input",function(n){clearTimeout(e),e=setTimeout(function(e){return o(n.target.value.trim())},200)})}function l(e,n){var t=h.getNode('.search input[type="search"]');if("string"==typeof e)t.placeholder=e;else{var r=Object.keys(e).find(function(e){return n.indexOf(e)>-1});t.placeholder=e[r]}}function p(e){h=Docsify.dom,a(),s(e),c()}function u(e,n){l(e.placeholder,n.route.path)}var d,h,f={},g={placeholder:"Type to search",paths:"auto",maxAge:864e5},m=function(e,n){var t=Docsify.util,r=n.config.search||g;Array.isArray(r)?g.paths=r:"object"==typeof r&&(g.paths=Array.isArray(r.paths)?r.paths:"auto",g.maxAge=t.isPrimitive(r.maxAge)?r.maxAge:g.maxAge,g.placeholder=r.placeholder||g.placeholder);var i="auto"===g.paths;e.mounted(function(e){p(g),!i&&o(g,n)}),e.doneEach(function(e){u(g,n),i&&o(g,n)})};window.$docsify.plugins=[].concat(m,window.$docsify.plugins)}();
|
||||
|
||||
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.0.3",
|
||||
"version": "3.0.5",
|
||||
"description": "A magical documentation generator.",
|
||||
"main": "lib/docsify.js",
|
||||
"files": [
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ const config = merge({
|
||||
themeColor: '',
|
||||
nameLink: window.location.pathname,
|
||||
autoHeader: false,
|
||||
executeScript: false,
|
||||
executeScript: null,
|
||||
ga: ''
|
||||
}, window.$docsify)
|
||||
|
||||
|
||||
@@ -12,14 +12,12 @@ export function btn (el) {
|
||||
el = dom.getNode(el)
|
||||
dom.on(el, 'click', toggle)
|
||||
|
||||
if (isMobile) {
|
||||
const sidebar = dom.getNode('.sidebar')
|
||||
const sidebar = dom.getNode('.sidebar')
|
||||
|
||||
dom.on(sidebar, 'click', () => {
|
||||
toggle()
|
||||
setTimeout(() => getAndActive(sidebar, true, true), 0)
|
||||
})
|
||||
}
|
||||
dom.on(sidebar, 'click', () => {
|
||||
isMobile && toggle()
|
||||
setTimeout(() => getAndActive(sidebar, true, true), 0)
|
||||
})
|
||||
}
|
||||
|
||||
export function sticky () {
|
||||
|
||||
@@ -2,7 +2,6 @@ import progressbar from '../render/progressbar'
|
||||
import { noop } from '../util/core'
|
||||
|
||||
const cache = {}
|
||||
const RUN_VERSION = Date.now()
|
||||
|
||||
/**
|
||||
* Simple ajax get
|
||||
@@ -16,8 +15,6 @@ export function get (url, hasBar = false) {
|
||||
xhr.addEventListener.apply(xhr, arguments)
|
||||
}
|
||||
|
||||
url += (/\?(\w+)=/g.test(url) ? '&' : '?') + `v=${RUN_VERSION}`
|
||||
|
||||
if (cache[url]) {
|
||||
return { then: cb => cb(cache[url]), abort: noop }
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ let markdownCompiler = marked
|
||||
let contentBase = ''
|
||||
let currentPath = ''
|
||||
let renderer = new marked.Renderer()
|
||||
const TOC = {}
|
||||
const cacheTree = {}
|
||||
let toc = []
|
||||
|
||||
/**
|
||||
@@ -120,11 +120,9 @@ export function sidebar (text, level) {
|
||||
export function subSidebar (el, level) {
|
||||
if (el) {
|
||||
toc[0] && toc[0].level === 1 && toc.shift()
|
||||
const tree = genTree(TOC[currentPath] || toc, level)
|
||||
const tree = cacheTree[currentPath] || genTree(toc, level)
|
||||
el.parentNode.innerHTML += treeTpl(tree, '<ul class="app-sub-sidebar">')
|
||||
}
|
||||
if (toc.length) {
|
||||
TOC[currentPath] = toc.slice()
|
||||
cacheTree[currentPath] = tree
|
||||
}
|
||||
toc = []
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@ export function genTree (toc, maxLevel) {
|
||||
|
||||
if (level > maxLevel) return
|
||||
if (last[len]) {
|
||||
last[len].children = last[len].children || []
|
||||
last[len].children.push(headline)
|
||||
last[len].children = (last[len].children || []).concat(headline)
|
||||
} else {
|
||||
headlines.push(headline)
|
||||
}
|
||||
|
||||
@@ -28,9 +28,8 @@ function renderMain (html) {
|
||||
this._renderTo('.markdown-section', html)
|
||||
// Render sidebar with the TOC
|
||||
!this.config.loadSidebar && this._renderSidebar()
|
||||
// execute script
|
||||
this.config.executeScript && executeScript()
|
||||
|
||||
// execute script
|
||||
if (this.config.executeScript !== false &&
|
||||
typeof window.Vue !== 'undefined' &&
|
||||
!executeScript()) {
|
||||
@@ -39,6 +38,8 @@ function renderMain (html) {
|
||||
vueVM && vueVM.$destroy && vueVM.$destroy()
|
||||
window.__EXECUTE_RESULT__ = new window.Vue().$mount('#main')
|
||||
}, 0)
|
||||
} else {
|
||||
this.config.executeScript && executeScript()
|
||||
}
|
||||
|
||||
if (this.config.auto2top) {
|
||||
@@ -53,11 +54,11 @@ export function renderMixin (proto) {
|
||||
}
|
||||
|
||||
proto._renderSidebar = function (text) {
|
||||
const { maxLevel, subMaxLevel, autoHeader } = this.config
|
||||
const { maxLevel, subMaxLevel, autoHeader, loadSidebar } = this.config
|
||||
|
||||
this._renderTo('.sidebar-nav', sidebar(text, maxLevel))
|
||||
const active = getAndActive('.sidebar-nav', true, true)
|
||||
subSidebar(active, subMaxLevel)
|
||||
loadSidebar && subSidebar(active, subMaxLevel)
|
||||
// bind event
|
||||
this.activeLink = active
|
||||
scrollActiveSidebar()
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
}
|
||||
|
||||
body:not(.ready) {
|
||||
overflow: hidden;
|
||||
|
||||
[data-cloak] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user