mirror of
https://github.com/wahyd4/docsify.git
synced 2026-08-24 12:46:08 +10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
543cbbce81 | ||
|
|
72c34152d4 | ||
|
|
44708554f7 | ||
|
|
6e35f6481a | ||
|
|
115c80b2f2 | ||
|
|
addb34d38a | ||
|
|
1f12009a98 | ||
|
|
4abcb02824 | ||
|
|
d45e325d54 | ||
|
|
f2f37eec46 | ||
|
|
fef969f55d | ||
|
|
5cc9f0514c | ||
|
|
ae1ad735d5 | ||
|
|
a35a336d00 | ||
|
|
3ec7c89bbb | ||
|
|
89f0b1fcbd | ||
|
|
6f5bb1a527 | ||
|
|
98ec020c7a | ||
|
|
bb13ddd5df | ||
|
|
e69efb8954 | ||
|
|
0e5f28cf60 | ||
|
|
7db1f1034a | ||
|
|
b0320416a5 | ||
|
|
4a77b8a7f3 | ||
|
|
00b13c5e86 | ||
|
|
82b7b8226d | ||
|
|
c9739e71af | ||
|
|
bda1b76ba5 | ||
|
|
11f77cd434 | ||
|
|
6d42c6b04a | ||
|
|
46967e73bf | ||
|
|
ccdc3c855a | ||
|
|
7c4b0b7c74 | ||
|
|
98d1b19bea | ||
|
|
0709239c77 | ||
|
|
73cc43c6bd | ||
|
|
9d096b03a4 | ||
|
|
2af035ff45 | ||
|
|
3979f5cd3f | ||
|
|
9abae495ac | ||
|
|
d179ade7df | ||
|
|
d79c7655cd | ||
|
|
af5d2934e4 | ||
|
|
129bd4d3a0 | ||
|
|
abaf5c0849 | ||
|
|
336efb30cb | ||
|
|
fb8bf89d73 | ||
|
|
8630591bd2 | ||
|
|
c47ff83073 | ||
|
|
69e500bd33 |
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"extends": ["vue"],
|
"extends": ["vue"],
|
||||||
"globals": {
|
"globals": {
|
||||||
"XMLHttpRequest": true
|
"XMLHttpRequest": true,
|
||||||
|
"__docsify__": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+69
-1
@@ -1,4 +1,72 @@
|
|||||||
## 1.7.1
|
## 2.0.2
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
- fix button style in cover page.
|
||||||
|
|
||||||
|
## 2.0.1
|
||||||
|
### Bug fixes
|
||||||
|
- border style.
|
||||||
|
|
||||||
|
## 2.0.0
|
||||||
|
### Features
|
||||||
|
- Customize the theme color
|
||||||
|
|
||||||
|
### Break change
|
||||||
|
- Remove `data-router`, `data-sidebar`, `data-sidebar-toggle` APIs
|
||||||
|
|
||||||
|
## 1.10.5
|
||||||
|
### Bug fixes
|
||||||
|
- fix initialize the Vue instance
|
||||||
|
|
||||||
|
## 1.10.4
|
||||||
|
### Bug fixes
|
||||||
|
- fix execute script
|
||||||
|
|
||||||
|
## 1.10.3
|
||||||
|
### Bug fixes
|
||||||
|
- compatible vuep QingWei-Li/vuep/issues/2
|
||||||
|
- fix sidebar scroll, fixed #63
|
||||||
|
|
||||||
|
## 1.10.2
|
||||||
|
### Bug fixes
|
||||||
|
- Fix render emojis again
|
||||||
|
|
||||||
|
## 1.10.1
|
||||||
|
### Bug fixes
|
||||||
|
- Fix render emojis
|
||||||
|
|
||||||
|
## 1.10.0
|
||||||
|
### Features
|
||||||
|
- Support emoji :laughing:
|
||||||
|
|
||||||
|
## 1.9.0
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
- Destroys the vue instance when the route is changed
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- Add `!>` and `?>` doc helper.
|
||||||
|
|
||||||
|
### Break change
|
||||||
|
- Remove `!` doc helper.
|
||||||
|
|
||||||
|
## 1.8.0
|
||||||
|
### Bug fixes
|
||||||
|
- Using `v-pre` skip compilation.
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- Execute script when vue exists.
|
||||||
|
|
||||||
|
## 1.7.4
|
||||||
|
### Bug fixes
|
||||||
|
- Fix bugs caused by the previous version
|
||||||
|
|
||||||
|
## 1.7.3
|
||||||
|
### Bug fixes
|
||||||
|
- Add `hr` style
|
||||||
|
- Fixed option is an empty string
|
||||||
|
|
||||||
|
## 1.7.2
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
- Fix sidebar click event in mobile browser.
|
- Fix sidebar click event in mobile browser.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2016 cinwell.li
|
Copyright (c) 2016 - 2017 cinwell.li
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -22,9 +22,10 @@
|
|||||||
- Simple and lightweight (~13kB gzipped)
|
- Simple and lightweight (~13kB gzipped)
|
||||||
- Multiple themes
|
- Multiple themes
|
||||||
- Not build static html files
|
- Not build static html files
|
||||||
|
- Support emoji :laughing:
|
||||||
|
|
||||||
## Quick start
|
## Quick start
|
||||||
Create a `index.html` and using `hash router`.
|
Create a `index.html`.
|
||||||
|
|
||||||
index.html
|
index.html
|
||||||
|
|
||||||
@@ -38,7 +39,7 @@ index.html
|
|||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
</body>
|
</body>
|
||||||
<script src="//unpkg.com/docsify" data-router></script>
|
<script src="//unpkg.com/docsify"></script>
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -46,6 +47,10 @@ index.html
|
|||||||
- UNPKG [https://unpkg.com/docsify/](https://unpkg.com/docsify/)
|
- UNPKG [https://unpkg.com/docsify/](https://unpkg.com/docsify/)
|
||||||
- jsDelivr [http://www.jsdelivr.com/projects/docsify](http://www.jsdelivr.com/projects/docsify)
|
- jsDelivr [http://www.jsdelivr.com/projects/docsify](http://www.jsdelivr.com/projects/docsify)
|
||||||
|
|
||||||
|
## Browser Support
|
||||||
|
|
||||||
|
Modern browsers and Internet Explorer 9+.
|
||||||
|
|
||||||
## Showcase
|
## 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 : )
|
||||||
|
|
||||||
@@ -53,6 +58,8 @@ These open-source projects are using docsify to generate their sites. Pull reque
|
|||||||
- [Snipaste](https://docs.snipaste.com/) - A new way to boost your productivity.
|
- [Snipaste](https://docs.snipaste.com/) - A new way to boost your productivity.
|
||||||
- [puck](https://puck.zz173.com/) - A small & magical php framework.
|
- [puck](https://puck.zz173.com/) - A small & magical php framework.
|
||||||
- [Samaritan](http://samaritan.stockdb.org) - An Algorithmic Trading Framework for Digital Currency.
|
- [Samaritan](http://samaritan.stockdb.org) - An Algorithmic Trading Framework for Digital Currency.
|
||||||
|
- [Vudash](http://vudash.github.io/vudash/) - Powerful, Flexible, Open Source dashboards for anything
|
||||||
|
- [Trilogy](http://trilogy.js.org) - No-hassle SQLite with a Promise-based, document store style API.
|
||||||
|
|
||||||
## Similar projects
|
## Similar projects
|
||||||
- [docute](https://github.com/egoist/docute) - 📜 Effortlessly documentation done right
|
- [docute](https://github.com/egoist/docute) - 📜 Effortlessly documentation done right
|
||||||
|
|||||||
+9
-1
@@ -3,7 +3,15 @@ var cssnano = require('cssnano').process
|
|||||||
var resolve = require('path').resolve
|
var resolve = require('path').resolve
|
||||||
var postcss = require('postcss')
|
var postcss = require('postcss')
|
||||||
|
|
||||||
var processor = postcss([require('postcss-salad')])
|
var processor = postcss([require('postcss-salad')({
|
||||||
|
features: {
|
||||||
|
precss: {
|
||||||
|
properties: {
|
||||||
|
preserve: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})])
|
||||||
|
|
||||||
var saveMin = function (file, content) {
|
var saveMin = function (file, content) {
|
||||||
fs.writeFileSync(resolve(__dirname, '../lib/themes/', file), content)
|
fs.writeFileSync(resolve(__dirname, '../lib/themes/', file), content)
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||||
<link rel="stylesheet" href="/themes/vue.css">
|
<link rel="stylesheet" href="/themes/vue.css">
|
||||||
</head>
|
</head>
|
||||||
<body class="">
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
</body>
|
</body>
|
||||||
<script src="/lib/docsify.js" data-repo="qingwei-li/docsify" data-name="docsify" data-auto2top data-sidebar-toggle data-router></script>
|
<script src="/lib/docsify.js" data-repo="qingwei-li/docsify" data-name="docsify" data-auto2top></script>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+59
-65
@@ -20,7 +20,7 @@ Create a `index.html` file
|
|||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
</body>
|
</body>
|
||||||
<script src="//unpkg.com/docsify" data-router></script>
|
<script src="//unpkg.com/docsify"></script>
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -160,10 +160,10 @@ window.$docsify = {
|
|||||||
### Doc Helpers
|
### Doc Helpers
|
||||||
#### p.tip
|
#### p.tip
|
||||||
|
|
||||||
'! ' add your content will rendered as `<p class="tip">content</p>`
|
`!> ` add your content will rendered as `<p class="tip">content</p>`
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
! Important **information**
|
!> Important **information**
|
||||||
```
|
```
|
||||||
|
|
||||||
It will be rendered
|
It will be rendered
|
||||||
@@ -174,9 +174,48 @@ It will be rendered
|
|||||||
|
|
||||||
e.g.
|
e.g.
|
||||||
|
|
||||||
! Important **information**
|
!> Important **information**
|
||||||
|
|
||||||
|
|
||||||
|
#### p.warn
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
?> todo info
|
||||||
|
```
|
||||||
|
|
||||||
|
?> todo info
|
||||||
|
|
||||||
|
### Combining Vue
|
||||||
|
We can write the Vue syntax directly in the markdown file, when the Vue library is loaded into `index.html`. Default will automatically initialize a Vue instance, of course, we can also manually.
|
||||||
|
|
||||||
|
index.html
|
||||||
|
```html
|
||||||
|
<script src="//unpkg.com/vue"></script>
|
||||||
|
<script src="//unpkg.com/docsify"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
<ul>
|
||||||
|
<li v-for="i in 10">{{ i }}</li>
|
||||||
|
</ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
Manual initialization
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
<div>
|
||||||
|
<input type="text" v-model="msg">
|
||||||
|
<p>Hello, {{ msg }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
new Vue({
|
||||||
|
el: 'main',
|
||||||
|
data: { msg: 'Docsify' }
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
You can add configurations in the script tag attributes or with `window.$docsify`.
|
You can add configurations in the script tag attributes or with `window.$docsify`.
|
||||||
@@ -221,50 +260,6 @@ window.$docsify = {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### sidebar-toggle
|
|
||||||
|
|
||||||
Sidebar with toggle
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script src="//unpkg.com/docsify" data-sidebar-toggle></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
```js
|
|
||||||
window.$docsify = {
|
|
||||||
sidebarToggle: true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### sidebar
|
|
||||||
|
|
||||||
Custom sidebar. If it's set, the TOC will be disabled. Bind global variables on the `data-sidebar`.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
window.sidebar = [
|
|
||||||
{ slug: '/', title: 'Home' },
|
|
||||||
{
|
|
||||||
slug: '/pageA',
|
|
||||||
title: 'page A',
|
|
||||||
children: [
|
|
||||||
{ slug: '/pageA/childrenB', title: 'children B' }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{ slug: '/PageC', title: 'Page C' }
|
|
||||||
]
|
|
||||||
</script>
|
|
||||||
<script src="/lib/docsify.js" data-sidebar="sidebar"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
```js
|
|
||||||
window.$docsify = {
|
|
||||||
sidebar: 'sidebar'
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### load-sidebar
|
### load-sidebar
|
||||||
|
|
||||||
Load sidebar markdown file. If it is configured, load the current directory `_sidebar.md` by default. If the file doesn't exist, the sidebar will appear as a TOC.
|
Load sidebar markdown file. If it is configured, load the current directory `_sidebar.md` by default. If the file doesn't exist, the sidebar will appear as a TOC.
|
||||||
@@ -349,20 +344,6 @@ If you write a sub level list, it will generate a dropdown list.
|
|||||||
- [chinese](/zh-cn)
|
- [chinese](/zh-cn)
|
||||||
```
|
```
|
||||||
|
|
||||||
### router
|
|
||||||
|
|
||||||
Hash router.
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script src="/lib/docsify.js" data-router></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
```js
|
|
||||||
window.$docsify = {
|
|
||||||
router: true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
### auto2top
|
### auto2top
|
||||||
|
|
||||||
@@ -384,7 +365,7 @@ window.$docsify = {
|
|||||||
|
|
||||||
### homepage
|
### homepage
|
||||||
|
|
||||||
`README.md` will be rendered as a homepage for your website in the docs folder, but sometimes we want to specify another file as a homepage, or even use the `README.md` in your repo. We can use (need `data-router`):
|
`README.md` will be rendered as a homepage for your website in the docs folder, but sometimes we want to specify another file as a homepage, or even use the `README.md` in your repo.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script src="/lib/docsify.js" data-homepage="https://raw.githubusercontent.com/QingWei-Li/docsify/master/README.md"></script>
|
<script src="/lib/docsify.js" data-homepage="https://raw.githubusercontent.com/QingWei-Li/docsify/master/README.md"></script>
|
||||||
@@ -400,7 +381,7 @@ window.$docsify = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### basePath
|
### base-path
|
||||||
|
|
||||||
If your HTML entry file and the markdown files are in different directories, we can use:
|
If your HTML entry file and the markdown files are in different directories, we can use:
|
||||||
|
|
||||||
@@ -449,7 +430,7 @@ window.$docsify = {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### nameLink
|
### name-link
|
||||||
|
|
||||||
Name link. The default value is `window.location.pathname`.
|
Name link. The default value is `window.location.pathname`.
|
||||||
|
|
||||||
@@ -464,4 +445,17 @@ window.$docsify = {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### theme-color
|
||||||
|
|
||||||
|
Customize the theme color.
|
||||||
|
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script src="/lib/docsify.js" data-theme-color="#3F51B5"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.$docsify = {
|
||||||
|
themeColor: '#3F51B5'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
+3
-2
@@ -1,12 +1,13 @@
|
|||||||

|

|
||||||
|
|
||||||
# docsify <small>1.7.2</small>
|
# docsify <small>2.0.2</small>
|
||||||
|
|
||||||
> A magical documentation site generator.
|
> A magical documentation site generator.
|
||||||
|
|
||||||
- Simple and lightweight (~13kB gzipped)
|
- Simple and lightweight (~13kB gzipped)
|
||||||
- Multiple themes
|
|
||||||
- Not build static html files
|
- Not build static html files
|
||||||
|
- Support emoji :laughing:
|
||||||
|
- Multiple themes
|
||||||
|
|
||||||
|
|
||||||
[GitHub](https://github.com/QingWei-Li/docsify/)
|
[GitHub](https://github.com/QingWei-Li/docsify/)
|
||||||
|
|||||||
+1
-3
@@ -18,10 +18,8 @@
|
|||||||
<script
|
<script
|
||||||
src="//unpkg.com/docsify/lib/docsify.min.js"
|
src="//unpkg.com/docsify/lib/docsify.min.js"
|
||||||
data-max-level="4"
|
data-max-level="4"
|
||||||
data-sidebar-toggle
|
|
||||||
data-coverpage
|
data-coverpage
|
||||||
data-name="docsify"
|
data-name="docsify"></script>
|
||||||
data-router></script>
|
|
||||||
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
|
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
|
||||||
<script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script>
|
<script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+65
-66
@@ -25,7 +25,7 @@ mkdir docs && cd docs
|
|||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
</body>
|
</body>
|
||||||
<script src="//unpkg.com/docsify" data-router></script>
|
<script src="//unpkg.com/docsify"></script>
|
||||||
</html>
|
</html>
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -166,10 +166,10 @@ window.$docsify = {
|
|||||||
### 文档助手
|
### 文档助手
|
||||||
#### 内置「提示」语法
|
#### 内置「提示」语法
|
||||||
|
|
||||||
感叹号加空格,后面接内容,会渲染成带 tip 类名的段落。
|
`!>`后面接内容,会渲染成带 tip 类名的段落。
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
! 提示信息,**支持其他 markdown 语法**
|
!> 提示信息,**支持其他 markdown 语法**
|
||||||
```
|
```
|
||||||
|
|
||||||
将被渲染成
|
将被渲染成
|
||||||
@@ -180,7 +180,51 @@ window.$docsify = {
|
|||||||
|
|
||||||
效果
|
效果
|
||||||
|
|
||||||
! 适合显示醒目的内容
|
!> 适合显示醒目的内容
|
||||||
|
|
||||||
|
#### 内置「警示」语法
|
||||||
|
|
||||||
|
`?>`后面接内容,会渲染成带 warn 类名的段落。
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
?> 警示内容样式
|
||||||
|
```
|
||||||
|
|
||||||
|
效果
|
||||||
|
|
||||||
|
?> 警示内容样式
|
||||||
|
|
||||||
|
### 结合 Vue
|
||||||
|
|
||||||
|
`index.html` 内引入 Vue 后,可以在文档里直接写 Vue 语法。默认会自己初始化一个 Vue 示例,当然我们也可以手动初始化一个实例。
|
||||||
|
|
||||||
|
index.html
|
||||||
|
```html
|
||||||
|
<script src="//unpkg.com/vue"></script>
|
||||||
|
<script src="//unpkg.com/docsify"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
<ul>
|
||||||
|
<li v-for="i in 10">{{ i }}</li>
|
||||||
|
</ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
手动初始化示例
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
<div>
|
||||||
|
<input type="text" v-model="msg">
|
||||||
|
<p>Hello, {{ msg }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
new Vue({
|
||||||
|
el: 'main',
|
||||||
|
data: { msg: 'Docsify' }
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
## 配置参数
|
## 配置参数
|
||||||
|
|
||||||
@@ -227,51 +271,6 @@ window.$docsify = {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### sidebar-toggle
|
|
||||||
|
|
||||||
Sidebar 开关按钮
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script src="//unpkg.com/docsify" data-sidebar-toggle></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
```js
|
|
||||||
window.$docsify = {
|
|
||||||
sidebarToggle: true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### sidebar
|
|
||||||
|
|
||||||
设置后 TOC 功能将不可用,适合导航较多的文档,`data-sidebar` 传入全局变量名。
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
```html
|
|
||||||
<script>
|
|
||||||
window.sidebar = [
|
|
||||||
{ slug: '/', title: 'Home' },
|
|
||||||
{
|
|
||||||
slug: '/pageA',
|
|
||||||
title: 'page A',
|
|
||||||
children: [
|
|
||||||
{ slug: '/pageA/childrenB', title: 'children B' }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{ slug: '/PageC', title: 'Page C' }
|
|
||||||
]
|
|
||||||
</script>
|
|
||||||
<script src="/lib/docsify.js" data-sidebar="sidebar"></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
```js
|
|
||||||
window.$docsify = {
|
|
||||||
sidebar: 'sidebar'
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### load-sidebar
|
### load-sidebar
|
||||||
|
|
||||||
读取侧边栏配置文件,如果配置,默认加载当前目录下的 `_sidebar.md`。如果文件不存在,会显示 TOC 作为侧边栏内容。如果你有二级目录,也应该放置一份配置文件。
|
读取侧边栏配置文件,如果配置,默认加载当前目录下的 `_sidebar.md`。如果文件不存在,会显示 TOC 作为侧边栏内容。如果你有二级目录,也应该放置一份配置文件。
|
||||||
@@ -356,20 +355,6 @@ window.$docsify = {
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### router
|
|
||||||
|
|
||||||
开启 hash router 功能,同时多页面切换不会重新加载资源。资源路径会被替换成 `/#/` 的形式。
|
|
||||||
|
|
||||||
```html
|
|
||||||
<script src="/lib/docsify.js" data-router></script>
|
|
||||||
```
|
|
||||||
|
|
||||||
```js
|
|
||||||
window.$docsify = {
|
|
||||||
router: true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### auto2top
|
### auto2top
|
||||||
|
|
||||||
切换路由时自动跳转到页面顶部
|
切换路由时自动跳转到页面顶部
|
||||||
@@ -387,7 +372,7 @@ window.$docsify = {
|
|||||||
|
|
||||||
### homepage
|
### homepage
|
||||||
|
|
||||||
默认情况下网站会将根目录下 `README.md` 作为首页渲染,但是有些时候我们想指定其他文件,甚至想直接将 repo 下的 README 作为首页。你可以这样做(需要设置 `data-router`):
|
默认情况下网站会将根目录下 `README.md` 作为首页渲染,但是有些时候我们想指定其他文件,甚至想直接将 repo 下的 README 作为首页。
|
||||||
|
|
||||||
|
|
||||||
```html
|
```html
|
||||||
@@ -402,7 +387,7 @@ window.$docsify = {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### basePath
|
### base-path
|
||||||
|
|
||||||
指定加载文档的路径,如果你的 HTML 入口文件和文档是放在不同地方,你可以设置:
|
指定加载文档的路径,如果你的 HTML 入口文件和文档是放在不同地方,你可以设置:
|
||||||
|
|
||||||
@@ -453,7 +438,7 @@ window.$docsify = {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### nameLink
|
### name-link
|
||||||
|
|
||||||
项目名链接,默认为 `window.location.pathname`。
|
项目名链接,默认为 `window.location.pathname`。
|
||||||
|
|
||||||
@@ -467,3 +452,17 @@ window.$docsify = {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### theme-color
|
||||||
|
|
||||||
|
自定义主题色。
|
||||||
|
|
||||||
|
|
||||||
|
```html
|
||||||
|
<script src="/lib/docsify.js" data-theme-color="#3F51B5"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
window.$docsify = {
|
||||||
|
themeColor: '#3F51B5'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
+127
-52
@@ -168,6 +168,12 @@ var merge = Object.assign || function (to) {
|
|||||||
return to
|
return to
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function emojify (text) {
|
||||||
|
return text
|
||||||
|
.replace(/:(\w*?):/ig, '<img class="emoji" src="https://assets-cdn.github.com/images/icons/emoji/$1.png" alt="$1" />')
|
||||||
|
.replace(/__colon__/g, ':')
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Active sidebar when scroll
|
* Active sidebar when scroll
|
||||||
* @link https://buble.surge.sh/
|
* @link https://buble.surge.sh/
|
||||||
@@ -178,6 +184,8 @@ function scrollActiveSidebar () {
|
|||||||
var hoveredOverSidebar = false;
|
var hoveredOverSidebar = false;
|
||||||
var anchors = document.querySelectorAll('.anchor');
|
var anchors = document.querySelectorAll('.anchor');
|
||||||
var sidebar = document.querySelector('aside.sidebar');
|
var sidebar = document.querySelector('aside.sidebar');
|
||||||
|
var sidebarHeight = sidebar.clientHeight;
|
||||||
|
|
||||||
var nav = {};
|
var nav = {};
|
||||||
var lis = sidebar.querySelectorAll('li');
|
var lis = sidebar.querySelectorAll('li');
|
||||||
var active = sidebar.querySelector('li.active');
|
var active = sidebar.querySelector('li.active');
|
||||||
@@ -216,7 +224,25 @@ function scrollActiveSidebar () {
|
|||||||
|
|
||||||
li.classList.add('active');
|
li.classList.add('active');
|
||||||
active = li;
|
active = li;
|
||||||
!hoveredOverSidebar && !sticky.noSticky && active.scrollIntoView(false);
|
|
||||||
|
// scroll into view
|
||||||
|
// https://github.com/vuejs/vuejs.org/blob/master/themes/vue/source/js/common.js#L282-L297
|
||||||
|
if (!hoveredOverSidebar && !sticky.noSticky) {
|
||||||
|
var currentPageOffset = 0;
|
||||||
|
var currentActiveOffset = active.offsetTop + active.clientHeight + 40;
|
||||||
|
var currentActiveIsInView = (
|
||||||
|
active.offsetTop >= sidebar.scrollTop &&
|
||||||
|
currentActiveOffset <= sidebar.scrollTop + sidebarHeight
|
||||||
|
);
|
||||||
|
var linkNotFurtherThanSidebarHeight = currentActiveOffset - currentPageOffset < sidebarHeight;
|
||||||
|
var newScrollTop = currentActiveIsInView
|
||||||
|
? sidebar.scrollTop
|
||||||
|
: linkNotFurtherThanSidebarHeight
|
||||||
|
? currentPageOffset
|
||||||
|
: currentActiveOffset - sidebarHeight;
|
||||||
|
|
||||||
|
sidebar.scrollTop = newScrollTop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.removeEventListener('scroll', highlight);
|
window.removeEventListener('scroll', highlight);
|
||||||
@@ -2421,8 +2447,8 @@ function corner (data) {
|
|||||||
/**
|
/**
|
||||||
* Render main content
|
* Render main content
|
||||||
*/
|
*/
|
||||||
function main (tpl) {
|
function main () {
|
||||||
var aside = tpl + "<aside class=\"sidebar\"></aside>";
|
var aside = (toggle()) + "<aside class=\"sidebar\"></aside>";
|
||||||
|
|
||||||
return (isMobile() ? (aside + "<main>") : ("<main>" + aside)) +
|
return (isMobile() ? (aside + "<main>") : ("<main>" + aside)) +
|
||||||
"<section class=\"content\">\n <article class=\"markdown-section\"></article>\n </section>\n </main>"
|
"<section class=\"content\">\n <article class=\"markdown-section\"></article>\n </section>\n </main>"
|
||||||
@@ -2463,11 +2489,41 @@ function tree (toc, tpl) {
|
|||||||
return tpl
|
return tpl
|
||||||
}
|
}
|
||||||
|
|
||||||
var OPTIONS$1 = {};
|
function helper (className, content) {
|
||||||
|
return ("<p class=\"" + className + "\">" + (content.slice(5).trim()) + "</p>")
|
||||||
|
}
|
||||||
|
|
||||||
|
function theme (color) {
|
||||||
|
return ("<style>:root{--theme-color: " + color + ";}</style>")
|
||||||
|
}
|
||||||
|
|
||||||
|
function replaceVar (block) {
|
||||||
|
block.innerHTML = block.innerHTML.replace(/var\(\s*--theme-color.*?\)/g, __docsify__.themeColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
function cssVars () {
|
||||||
|
// variable support
|
||||||
|
if (window.CSS && window.CSS.supports && window.CSS.supports('(--foo: red)')) { return }
|
||||||
|
|
||||||
|
var styleBlocks = document.querySelectorAll('style:not(.inserted),link');[].forEach.call(styleBlocks, function (block) {
|
||||||
|
if (block.nodeName === 'STYLE') {
|
||||||
|
replaceVar(block);
|
||||||
|
} else if (block.nodeName === 'LINK') {
|
||||||
|
load(block.getAttribute('href'))
|
||||||
|
.then(function (res) {
|
||||||
|
var style = document.createElement('style');
|
||||||
|
|
||||||
|
style.innerHTML = res;
|
||||||
|
document.head.appendChild(style);
|
||||||
|
replaceVar(style);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var markdown = marked;
|
var markdown = marked;
|
||||||
var toc = [];
|
var toc = [];
|
||||||
var CACHE = {};
|
var CACHE = {};
|
||||||
var TIP_RE = /^!\s/;
|
|
||||||
|
|
||||||
var renderTo = function (dom, content) {
|
var renderTo = function (dom, content) {
|
||||||
dom = typeof dom === 'object' ? dom : document.querySelector(dom);
|
dom = typeof dom === 'object' ? dom : document.querySelector(dom);
|
||||||
@@ -2479,11 +2535,8 @@ var renderTo = function (dom, content) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* init render
|
* init render
|
||||||
* @param {Object} options
|
|
||||||
*/
|
*/
|
||||||
function init (options) {
|
function init () {
|
||||||
OPTIONS$1 = options;
|
|
||||||
|
|
||||||
var renderer = new marked.Renderer();
|
var renderer = new marked.Renderer();
|
||||||
/**
|
/**
|
||||||
* render anchor tag
|
* render anchor tag
|
||||||
@@ -2493,10 +2546,7 @@ function init (options) {
|
|||||||
var slug = slugify(text);
|
var slug = slugify(text);
|
||||||
var route = '';
|
var route = '';
|
||||||
|
|
||||||
if (OPTIONS$1.router) {
|
route = "#/" + (getRoute());
|
||||||
route = "#/" + (getRoute());
|
|
||||||
}
|
|
||||||
|
|
||||||
toc.push({ level: level, slug: (route + "#" + (encodeURIComponent(slug))), title: text });
|
toc.push({ level: level, slug: (route + "#" + (encodeURIComponent(slug))), title: text });
|
||||||
|
|
||||||
return ("<h" + level + " id=\"" + slug + "\"><a href=\"" + route + "#" + slug + "\" data-id=\"" + slug + "\" class=\"anchor\"><span>" + text + "</span></a></h" + level + ">")
|
return ("<h" + level + " id=\"" + slug + "\"><a href=\"" + route + "#" + slug + "\" data-id=\"" + slug + "\" class=\"anchor\"><span>" + text + "</span></a></h" + level + ">")
|
||||||
@@ -2505,29 +2555,36 @@ function init (options) {
|
|||||||
renderer.code = function (code, lang) {
|
renderer.code = function (code, lang) {
|
||||||
if ( lang === void 0 ) lang = '';
|
if ( lang === void 0 ) lang = '';
|
||||||
|
|
||||||
var hl = prism.highlight(code, prism.languages[lang] || prism.languages.markup)
|
var hl = prism.highlight(code, prism.languages[lang] || prism.languages.markup);
|
||||||
.replace(/{{/g, '<span>{{</span>');
|
|
||||||
|
|
||||||
return ("<pre data-lang=\"" + lang + "\"><code class=\"lang-" + lang + "\">" + hl + "</code></pre>")
|
return ("<pre v-pre data-lang=\"" + lang + "\"><code class=\"lang-" + lang + "\">" + (hl.replace(/:/g, '__colon__')) + "</code></pre>")
|
||||||
};
|
};
|
||||||
renderer.link = function (href, title, text) {
|
renderer.link = function (href, title, text) {
|
||||||
if (OPTIONS$1.router && !/:/.test(href)) {
|
if (!/:/.test(href)) {
|
||||||
href = ("#/" + href).replace(/\/\//g, '/');
|
href = ("#/" + href).replace(/\/\//g, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
return ("<a href=\"" + href + "\" title=\"" + (title || '') + "\">" + text + "</a>")
|
return ("<a href=\"" + href + "\" title=\"" + (title || '') + "\">" + text + "</a>")
|
||||||
};
|
};
|
||||||
renderer.paragraph = function (text) {
|
renderer.paragraph = function (text) {
|
||||||
var isTip = TIP_RE.test(text);
|
if (/^!>/.test(text)) {
|
||||||
return isTip ? ("<p class=\"tip\">" + (text.replace(TIP_RE, '')) + "</p>") : ("<p>" + text + "</p>")
|
return helper('tip', text)
|
||||||
|
} else if (/^\?>/.test(text)) {
|
||||||
|
return helper('warn', text)
|
||||||
|
}
|
||||||
|
return ("<p>" + text + "</p>")
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof OPTIONS$1.markdown === 'function') {
|
if (typeof __docsify__.markdown === 'function') {
|
||||||
markdown.setOptions({ renderer: renderer });
|
markdown.setOptions({ renderer: renderer });
|
||||||
markdown = OPTIONS$1.markdown.call(this, markdown);
|
markdown = __docsify__.markdown.call(this, markdown);
|
||||||
} else {
|
} else {
|
||||||
markdown.setOptions(merge({ renderer: renderer }, OPTIONS$1.markdown));
|
markdown.setOptions(merge({ renderer: renderer }, __docsify__.markdown));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var md = markdown;
|
||||||
|
|
||||||
|
markdown = function (text) { return emojify(md(text)); };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2536,17 +2593,23 @@ function init (options) {
|
|||||||
function renderApp (dom, replace) {
|
function renderApp (dom, replace) {
|
||||||
var nav = document.querySelector('nav') || document.createElement('nav');
|
var nav = document.querySelector('nav') || document.createElement('nav');
|
||||||
|
|
||||||
if (!OPTIONS$1.repo) { nav.classList.add('no-badge'); }
|
if (!__docsify__.repo) { nav.classList.add('no-badge'); }
|
||||||
|
|
||||||
dom[replace ? 'outerHTML' : 'innerHTML'] = corner(OPTIONS$1.repo) +
|
dom[replace ? 'outerHTML' : 'innerHTML'] = corner(__docsify__.repo) +
|
||||||
(OPTIONS$1.coverpage ? cover() : '') +
|
(__docsify__.coverpage ? cover() : '') +
|
||||||
main(OPTIONS$1.sidebarToggle ? toggle() : '');
|
main();
|
||||||
document.body.insertBefore(nav, document.body.children[0]);
|
document.body.insertBefore(nav, document.body.children[0]);
|
||||||
|
|
||||||
|
// theme color
|
||||||
|
if (__docsify__.themeColor) {
|
||||||
|
document.head.innerHTML += theme(__docsify__.themeColor);
|
||||||
|
cssVars();
|
||||||
|
}
|
||||||
|
|
||||||
// bind toggle
|
// bind toggle
|
||||||
bindToggle('button.sidebar-toggle');
|
bindToggle('button.sidebar-toggle');
|
||||||
// bind sticky effect
|
// bind sticky effect
|
||||||
if (OPTIONS$1.coverpage) {
|
if (__docsify__.coverpage) {
|
||||||
!isMobile() && window.addEventListener('scroll', sticky);
|
!isMobile() && window.addEventListener('scroll', sticky);
|
||||||
} else {
|
} else {
|
||||||
document.body.classList.add('sticky');
|
document.body.classList.add('sticky');
|
||||||
@@ -2558,13 +2621,24 @@ function renderApp (dom, replace) {
|
|||||||
*/
|
*/
|
||||||
function renderArticle (content) {
|
function renderArticle (content) {
|
||||||
renderTo('article', content ? markdown(content) : 'not found');
|
renderTo('article', content ? markdown(content) : 'not found');
|
||||||
if (!OPTIONS$1.sidebar && !OPTIONS$1.loadSidebar) { renderSidebar(); }
|
if (!__docsify__.loadSidebar) { renderSidebar(); }
|
||||||
|
|
||||||
if (content && typeof Vue !== 'undefined' && typeof Vuep !== 'undefined') {
|
if (content && typeof Vue !== 'undefined') {
|
||||||
var vm = new Vue({ el: 'main' }); // eslint-disable-line
|
CACHE.vm && CACHE.vm.$destroy();
|
||||||
vm.$nextTick(function (_) { return scrollActiveSidebar(); });
|
|
||||||
|
var script = [].slice.call(
|
||||||
|
document.body.querySelectorAll('article>script'))
|
||||||
|
.filter(function (script) { return !/template/.test(script.type); }
|
||||||
|
)[0];
|
||||||
|
var code = script ? script.innerText.trim() : null;
|
||||||
|
|
||||||
|
script && script.remove();
|
||||||
|
CACHE.vm = code
|
||||||
|
? new Function(("return " + code))()
|
||||||
|
: new Vue({ el: 'main' }); // eslint-disable-line
|
||||||
|
CACHE.vm && CACHE.vm.$nextTick(function (_) { return scrollActiveSidebar(); });
|
||||||
}
|
}
|
||||||
if (OPTIONS$1.auto2top) { setTimeout(function () { return scroll2Top(OPTIONS$1.auto2top); }, 0); }
|
if (__docsify__.auto2top) { setTimeout(function () { return scroll2Top(__docsify__.auto2top); }, 0); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2588,13 +2662,11 @@ function renderSidebar (content) {
|
|||||||
html = markdown(content);
|
html = markdown(content);
|
||||||
// find url tag
|
// find url tag
|
||||||
html = html.match(/<ul[^>]*>([\s\S]+)<\/ul>/g)[0];
|
html = html.match(/<ul[^>]*>([\s\S]+)<\/ul>/g)[0];
|
||||||
} else if (OPTIONS$1.sidebar) {
|
|
||||||
html = tree(OPTIONS$1.sidebar, '<ul>');
|
|
||||||
} else {
|
} else {
|
||||||
html = tree(genTree(toc, OPTIONS$1.maxLevel), '<ul>');
|
html = tree(genTree(toc, __docsify__.maxLevel), '<ul>');
|
||||||
}
|
}
|
||||||
|
|
||||||
html = (OPTIONS$1.name ? ("<h1><a href=\"" + (OPTIONS$1.nameLink) + "\">" + (OPTIONS$1.name) + "</a></h1>") : '') + html;
|
html = (__docsify__.name ? ("<h1><a href=\"" + (__docsify__.nameLink) + "\">" + (__docsify__.name) + "</a></h1>") : '') + html;
|
||||||
renderTo('aside.sidebar', html);
|
renderTo('aside.sidebar', html);
|
||||||
var target = activeLink('aside.sidebar', true);
|
var target = activeLink('aside.sidebar', true);
|
||||||
if (target) { renderSubSidebar(target); }
|
if (target) { renderSubSidebar(target); }
|
||||||
@@ -2604,8 +2676,8 @@ function renderSidebar (content) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderSubSidebar (target) {
|
function renderSubSidebar (target) {
|
||||||
if (!OPTIONS$1.subMaxLevel) { return }
|
if (!__docsify__.subMaxLevel) { return }
|
||||||
target.parentNode.innerHTML += tree(genTree(toc, OPTIONS$1.subMaxLevel), '<ul>');
|
target.parentNode.innerHTML += tree(genTree(toc, __docsify__.subMaxLevel), '<ul>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2621,9 +2693,12 @@ function renderCover (content) {
|
|||||||
if (renderCover.rendered) { return sticky() }
|
if (renderCover.rendered) { return sticky() }
|
||||||
|
|
||||||
// render cover
|
// render cover
|
||||||
|
var cacheToc = toc.slice();
|
||||||
var html = markdown(content);
|
var html = markdown(content);
|
||||||
var match = html.trim().match('<p><img[^s]+src="(.*?)"[^a]+alt="(.*?)">([^<]*?)</p>$');
|
var match = html.trim().match('<p><img[^s]+src="(.*?)"[^a]+alt="(.*?)">([^<]*?)</p>$');
|
||||||
|
|
||||||
|
toc = cacheToc.slice();
|
||||||
|
|
||||||
// render background
|
// render background
|
||||||
if (match) {
|
if (match) {
|
||||||
var coverEl = document.querySelector('section.cover');
|
var coverEl = document.querySelector('section.cover');
|
||||||
@@ -2685,16 +2760,14 @@ var OPTIONS = merge({
|
|||||||
repo: '',
|
repo: '',
|
||||||
maxLevel: 6,
|
maxLevel: 6,
|
||||||
subMaxLevel: 0,
|
subMaxLevel: 0,
|
||||||
sidebar: '',
|
|
||||||
sidebarToggle: false,
|
|
||||||
loadSidebar: null,
|
loadSidebar: null,
|
||||||
loadNavbar: null,
|
loadNavbar: null,
|
||||||
router: false,
|
|
||||||
homepage: 'README.md',
|
homepage: 'README.md',
|
||||||
coverpage: '',
|
coverpage: '',
|
||||||
basePath: '',
|
basePath: '',
|
||||||
auto2top: false,
|
auto2top: false,
|
||||||
name: '',
|
name: '',
|
||||||
|
themeColor: '',
|
||||||
nameLink: window.location.pathname
|
nameLink: window.location.pathname
|
||||||
}, window.$docsify);
|
}, window.$docsify);
|
||||||
var script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop();
|
var script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop();
|
||||||
@@ -2708,9 +2781,13 @@ if (script) {
|
|||||||
if (OPTIONS.loadSidebar === true) { OPTIONS.loadSidebar = '_sidebar.md'; }
|
if (OPTIONS.loadSidebar === true) { OPTIONS.loadSidebar = '_sidebar.md'; }
|
||||||
if (OPTIONS.loadNavbar === true) { OPTIONS.loadNavbar = '_navbar.md'; }
|
if (OPTIONS.loadNavbar === true) { OPTIONS.loadNavbar = '_navbar.md'; }
|
||||||
if (OPTIONS.coverpage === true) { OPTIONS.coverpage = '_coverpage.md'; }
|
if (OPTIONS.coverpage === true) { OPTIONS.coverpage = '_coverpage.md'; }
|
||||||
if (OPTIONS.sidebar) { OPTIONS.sidebar = window[OPTIONS.sidebar]; }
|
if (OPTIONS.repo === true) { OPTIONS.repo = ''; }
|
||||||
|
if (OPTIONS.name === true) { OPTIONS.name = ''; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// utils
|
||||||
|
window.__docsify__ = OPTIONS;
|
||||||
|
|
||||||
// load options
|
// load options
|
||||||
init(OPTIONS);
|
init(OPTIONS);
|
||||||
|
|
||||||
@@ -2752,11 +2829,10 @@ var mainRender = function (cb) {
|
|||||||
if (OPTIONS.coverpage && page !== OPTIONS.homepage) { renderCover(); }
|
if (OPTIONS.coverpage && page !== OPTIONS.homepage) { renderCover(); }
|
||||||
// render sidebar
|
// render sidebar
|
||||||
if (OPTIONS.loadSidebar) {
|
if (OPTIONS.loadSidebar) {
|
||||||
load(basePath + OPTIONS.loadSidebar)
|
var renderSidebar$$1 = function (result) { renderSidebar(result); cb(); };
|
||||||
.then(function (result) {
|
|
||||||
renderSidebar(result);
|
load(basePath + OPTIONS.loadSidebar).then(renderSidebar$$1,
|
||||||
cb();
|
function (_) { return load(OPTIONS.loadSidebar).then(renderSidebar$$1); });
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
cb();
|
cb();
|
||||||
}
|
}
|
||||||
@@ -2764,7 +2840,8 @@ var mainRender = function (cb) {
|
|||||||
|
|
||||||
// Render navbar
|
// Render navbar
|
||||||
if (OPTIONS.loadNavbar) {
|
if (OPTIONS.loadNavbar) {
|
||||||
load(basePath + OPTIONS.loadNavbar).then(renderNavbar);
|
load(basePath + OPTIONS.loadNavbar).then(renderNavbar,
|
||||||
|
function (_) { return load(OPTIONS.loadNavbar).then(renderNavbar); });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2781,10 +2858,8 @@ var Docsify = function () {
|
|||||||
// Render app
|
// Render app
|
||||||
renderApp(dom, replace);
|
renderApp(dom, replace);
|
||||||
main();
|
main();
|
||||||
if (OPTIONS.router) {
|
if (!/^#\//.test(window.location.hash)) { window.location.hash = '#/'; }
|
||||||
if (!/^#\//.test(window.location.hash)) { window.location.hash = '#/'; }
|
window.addEventListener('hashchange', main);
|
||||||
window.addEventListener('hashchange', main);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var index = Docsify();
|
var index = Docsify();
|
||||||
|
|||||||
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
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "docsify",
|
"name": "docsify",
|
||||||
"version": "1.7.2",
|
"version": "2.0.2",
|
||||||
"description": "A magical documentation generator.",
|
"description": "A magical documentation generator.",
|
||||||
"main": "lib/docsify.js",
|
"main": "lib/docsify.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
+21
-1
@@ -10,6 +10,8 @@ export function scrollActiveSidebar () {
|
|||||||
let hoveredOverSidebar = false
|
let hoveredOverSidebar = false
|
||||||
const anchors = document.querySelectorAll('.anchor')
|
const anchors = document.querySelectorAll('.anchor')
|
||||||
const sidebar = document.querySelector('aside.sidebar')
|
const sidebar = document.querySelector('aside.sidebar')
|
||||||
|
const sidebarHeight = sidebar.clientHeight
|
||||||
|
|
||||||
const nav = {}
|
const nav = {}
|
||||||
const lis = sidebar.querySelectorAll('li')
|
const lis = sidebar.querySelectorAll('li')
|
||||||
let active = sidebar.querySelector('li.active')
|
let active = sidebar.querySelector('li.active')
|
||||||
@@ -48,7 +50,25 @@ export function scrollActiveSidebar () {
|
|||||||
|
|
||||||
li.classList.add('active')
|
li.classList.add('active')
|
||||||
active = li
|
active = li
|
||||||
!hoveredOverSidebar && !sticky.noSticky && active.scrollIntoView(false)
|
|
||||||
|
// scroll into view
|
||||||
|
// https://github.com/vuejs/vuejs.org/blob/master/themes/vue/source/js/common.js#L282-L297
|
||||||
|
if (!hoveredOverSidebar && !sticky.noSticky) {
|
||||||
|
const currentPageOffset = 0
|
||||||
|
const currentActiveOffset = active.offsetTop + active.clientHeight + 40
|
||||||
|
const currentActiveIsInView = (
|
||||||
|
active.offsetTop >= sidebar.scrollTop &&
|
||||||
|
currentActiveOffset <= sidebar.scrollTop + sidebarHeight
|
||||||
|
)
|
||||||
|
const linkNotFurtherThanSidebarHeight = currentActiveOffset - currentPageOffset < sidebarHeight
|
||||||
|
const newScrollTop = currentActiveIsInView
|
||||||
|
? sidebar.scrollTop
|
||||||
|
: linkNotFurtherThanSidebarHeight
|
||||||
|
? currentPageOffset
|
||||||
|
: currentActiveOffset - sidebarHeight
|
||||||
|
|
||||||
|
sidebar.scrollTop = newScrollTop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.removeEventListener('scroll', highlight)
|
window.removeEventListener('scroll', highlight)
|
||||||
|
|||||||
+14
-14
@@ -7,16 +7,14 @@ const OPTIONS = merge({
|
|||||||
repo: '',
|
repo: '',
|
||||||
maxLevel: 6,
|
maxLevel: 6,
|
||||||
subMaxLevel: 0,
|
subMaxLevel: 0,
|
||||||
sidebar: '',
|
|
||||||
sidebarToggle: false,
|
|
||||||
loadSidebar: null,
|
loadSidebar: null,
|
||||||
loadNavbar: null,
|
loadNavbar: null,
|
||||||
router: false,
|
|
||||||
homepage: 'README.md',
|
homepage: 'README.md',
|
||||||
coverpage: '',
|
coverpage: '',
|
||||||
basePath: '',
|
basePath: '',
|
||||||
auto2top: false,
|
auto2top: false,
|
||||||
name: '',
|
name: '',
|
||||||
|
themeColor: '',
|
||||||
nameLink: window.location.pathname
|
nameLink: window.location.pathname
|
||||||
}, window.$docsify)
|
}, window.$docsify)
|
||||||
const script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop()
|
const script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop()
|
||||||
@@ -30,9 +28,13 @@ if (script) {
|
|||||||
if (OPTIONS.loadSidebar === true) OPTIONS.loadSidebar = '_sidebar.md'
|
if (OPTIONS.loadSidebar === true) OPTIONS.loadSidebar = '_sidebar.md'
|
||||||
if (OPTIONS.loadNavbar === true) OPTIONS.loadNavbar = '_navbar.md'
|
if (OPTIONS.loadNavbar === true) OPTIONS.loadNavbar = '_navbar.md'
|
||||||
if (OPTIONS.coverpage === true) OPTIONS.coverpage = '_coverpage.md'
|
if (OPTIONS.coverpage === true) OPTIONS.coverpage = '_coverpage.md'
|
||||||
if (OPTIONS.sidebar) OPTIONS.sidebar = window[OPTIONS.sidebar]
|
if (OPTIONS.repo === true) OPTIONS.repo = ''
|
||||||
|
if (OPTIONS.name === true) OPTIONS.name = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// utils
|
||||||
|
window.__docsify__ = OPTIONS
|
||||||
|
|
||||||
// load options
|
// load options
|
||||||
render.init(OPTIONS)
|
render.init(OPTIONS)
|
||||||
|
|
||||||
@@ -74,11 +76,10 @@ const mainRender = function (cb) {
|
|||||||
if (OPTIONS.coverpage && page !== OPTIONS.homepage) render.renderCover()
|
if (OPTIONS.coverpage && page !== OPTIONS.homepage) render.renderCover()
|
||||||
// render sidebar
|
// render sidebar
|
||||||
if (OPTIONS.loadSidebar) {
|
if (OPTIONS.loadSidebar) {
|
||||||
load(basePath + OPTIONS.loadSidebar)
|
const renderSidebar = result => { render.renderSidebar(result); cb() }
|
||||||
.then(result => {
|
|
||||||
render.renderSidebar(result)
|
load(basePath + OPTIONS.loadSidebar).then(renderSidebar,
|
||||||
cb()
|
_ => load(OPTIONS.loadSidebar).then(renderSidebar))
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
cb()
|
cb()
|
||||||
}
|
}
|
||||||
@@ -86,7 +87,8 @@ const mainRender = function (cb) {
|
|||||||
|
|
||||||
// Render navbar
|
// Render navbar
|
||||||
if (OPTIONS.loadNavbar) {
|
if (OPTIONS.loadNavbar) {
|
||||||
load(basePath + OPTIONS.loadNavbar).then(render.renderNavbar)
|
load(basePath + OPTIONS.loadNavbar).then(render.renderNavbar,
|
||||||
|
_ => load(OPTIONS.loadNavbar).then(render.renderNavbar))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,10 +105,8 @@ const Docsify = function () {
|
|||||||
// Render app
|
// Render app
|
||||||
render.renderApp(dom, replace)
|
render.renderApp(dom, replace)
|
||||||
main()
|
main()
|
||||||
if (OPTIONS.router) {
|
if (!/^#\//.test(window.location.hash)) window.location.hash = '#/'
|
||||||
if (!/^#\//.test(window.location.hash)) window.location.hash = '#/'
|
window.addEventListener('hashchange', main)
|
||||||
window.addEventListener('hashchange', main)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Docsify()
|
export default Docsify()
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { load } from './util'
|
||||||
|
|
||||||
|
function replaceVar (block) {
|
||||||
|
block.innerHTML = block.innerHTML.replace(/var\(\s*--theme-color.*?\)/g, __docsify__.themeColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function cssVars () {
|
||||||
|
// variable support
|
||||||
|
if (window.CSS && window.CSS.supports && window.CSS.supports('(--foo: red)')) return
|
||||||
|
|
||||||
|
const styleBlocks = document.querySelectorAll('style:not(.inserted),link')
|
||||||
|
|
||||||
|
;[].forEach.call(styleBlocks, block => {
|
||||||
|
if (block.nodeName === 'STYLE') {
|
||||||
|
replaceVar(block)
|
||||||
|
} else if (block.nodeName === 'LINK') {
|
||||||
|
load(block.getAttribute('href'))
|
||||||
|
.then(res => {
|
||||||
|
const style = document.createElement('style')
|
||||||
|
|
||||||
|
style.innerHTML = res
|
||||||
|
document.head.appendChild(style)
|
||||||
|
replaceVar(style)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
+53
-35
@@ -2,13 +2,12 @@ import marked from 'marked'
|
|||||||
import Prism from 'prismjs'
|
import Prism from 'prismjs'
|
||||||
import * as tpl from './tpl'
|
import * as tpl from './tpl'
|
||||||
import * as event from './event'
|
import * as event from './event'
|
||||||
import { genTree, getRoute, isMobile, slugify, merge } from './util'
|
import * as polyfill from './polyfill'
|
||||||
|
import { genTree, getRoute, isMobile, slugify, merge, emojify } from './util'
|
||||||
|
|
||||||
let OPTIONS = {}
|
|
||||||
let markdown = marked
|
let markdown = marked
|
||||||
let toc = []
|
let toc = []
|
||||||
const CACHE = {}
|
const CACHE = {}
|
||||||
const TIP_RE = /^!\s/
|
|
||||||
|
|
||||||
const renderTo = function (dom, content) {
|
const renderTo = function (dom, content) {
|
||||||
dom = typeof dom === 'object' ? dom : document.querySelector(dom)
|
dom = typeof dom === 'object' ? dom : document.querySelector(dom)
|
||||||
@@ -20,11 +19,8 @@ const renderTo = function (dom, content) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* init render
|
* init render
|
||||||
* @param {Object} options
|
|
||||||
*/
|
*/
|
||||||
export function init (options) {
|
export function init () {
|
||||||
OPTIONS = options
|
|
||||||
|
|
||||||
const renderer = new marked.Renderer()
|
const renderer = new marked.Renderer()
|
||||||
/**
|
/**
|
||||||
* render anchor tag
|
* render anchor tag
|
||||||
@@ -34,10 +30,7 @@ export function init (options) {
|
|||||||
const slug = slugify(text)
|
const slug = slugify(text)
|
||||||
let route = ''
|
let route = ''
|
||||||
|
|
||||||
if (OPTIONS.router) {
|
route = `#/${getRoute()}`
|
||||||
route = `#/${getRoute()}`
|
|
||||||
}
|
|
||||||
|
|
||||||
toc.push({ level, slug: `${route}#${encodeURIComponent(slug)}`, title: text })
|
toc.push({ level, slug: `${route}#${encodeURIComponent(slug)}`, title: text })
|
||||||
|
|
||||||
return `<h${level} id="${slug}"><a href="${route}#${slug}" data-id="${slug}" class="anchor"><span>${text}</span></a></h${level}>`
|
return `<h${level} id="${slug}"><a href="${route}#${slug}" data-id="${slug}" class="anchor"><span>${text}</span></a></h${level}>`
|
||||||
@@ -45,28 +38,35 @@ export function init (options) {
|
|||||||
// highlight code
|
// highlight code
|
||||||
renderer.code = function (code, lang = '') {
|
renderer.code = function (code, lang = '') {
|
||||||
const hl = Prism.highlight(code, Prism.languages[lang] || Prism.languages.markup)
|
const hl = Prism.highlight(code, Prism.languages[lang] || Prism.languages.markup)
|
||||||
.replace(/{{/g, '<span>{{</span>')
|
|
||||||
|
|
||||||
return `<pre data-lang="${lang}"><code class="lang-${lang}">${hl}</code></pre>`
|
return `<pre v-pre data-lang="${lang}"><code class="lang-${lang}">${hl.replace(/:/g, '__colon__')}</code></pre>`
|
||||||
}
|
}
|
||||||
renderer.link = function (href, title, text) {
|
renderer.link = function (href, title, text) {
|
||||||
if (OPTIONS.router && !/:/.test(href)) {
|
if (!/:/.test(href)) {
|
||||||
href = `#/${href}`.replace(/\/\//g, '/')
|
href = `#/${href}`.replace(/\/\//g, '/')
|
||||||
}
|
}
|
||||||
|
|
||||||
return `<a href="${href}" title="${title || ''}">${text}</a>`
|
return `<a href="${href}" title="${title || ''}">${text}</a>`
|
||||||
}
|
}
|
||||||
renderer.paragraph = function (text) {
|
renderer.paragraph = function (text) {
|
||||||
const isTip = TIP_RE.test(text)
|
if (/^!>/.test(text)) {
|
||||||
return isTip ? `<p class="tip">${text.replace(TIP_RE, '')}</p>` : `<p>${text}</p>`
|
return tpl.helper('tip', text)
|
||||||
|
} else if (/^\?>/.test(text)) {
|
||||||
|
return tpl.helper('warn', text)
|
||||||
|
}
|
||||||
|
return `<p>${text}</p>`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof OPTIONS.markdown === 'function') {
|
if (typeof __docsify__.markdown === 'function') {
|
||||||
markdown.setOptions({ renderer })
|
markdown.setOptions({ renderer })
|
||||||
markdown = OPTIONS.markdown.call(this, markdown)
|
markdown = __docsify__.markdown.call(this, markdown)
|
||||||
} else {
|
} else {
|
||||||
markdown.setOptions(merge({ renderer }, OPTIONS.markdown))
|
markdown.setOptions(merge({ renderer }, __docsify__.markdown))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const md = markdown
|
||||||
|
|
||||||
|
markdown = text => emojify(md(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,17 +75,23 @@ export function init (options) {
|
|||||||
export function renderApp (dom, replace) {
|
export function renderApp (dom, replace) {
|
||||||
const nav = document.querySelector('nav') || document.createElement('nav')
|
const nav = document.querySelector('nav') || document.createElement('nav')
|
||||||
|
|
||||||
if (!OPTIONS.repo) nav.classList.add('no-badge')
|
if (!__docsify__.repo) nav.classList.add('no-badge')
|
||||||
|
|
||||||
dom[replace ? 'outerHTML' : 'innerHTML'] = tpl.corner(OPTIONS.repo) +
|
dom[replace ? 'outerHTML' : 'innerHTML'] = tpl.corner(__docsify__.repo) +
|
||||||
(OPTIONS.coverpage ? tpl.cover() : '') +
|
(__docsify__.coverpage ? tpl.cover() : '') +
|
||||||
tpl.main(OPTIONS.sidebarToggle ? tpl.toggle() : '')
|
tpl.main()
|
||||||
document.body.insertBefore(nav, document.body.children[0])
|
document.body.insertBefore(nav, document.body.children[0])
|
||||||
|
|
||||||
|
// theme color
|
||||||
|
if (__docsify__.themeColor) {
|
||||||
|
document.head.innerHTML += tpl.theme(__docsify__.themeColor)
|
||||||
|
polyfill.cssVars()
|
||||||
|
}
|
||||||
|
|
||||||
// bind toggle
|
// bind toggle
|
||||||
event.bindToggle('button.sidebar-toggle')
|
event.bindToggle('button.sidebar-toggle')
|
||||||
// bind sticky effect
|
// bind sticky effect
|
||||||
if (OPTIONS.coverpage) {
|
if (__docsify__.coverpage) {
|
||||||
!isMobile() && window.addEventListener('scroll', event.sticky)
|
!isMobile() && window.addEventListener('scroll', event.sticky)
|
||||||
} else {
|
} else {
|
||||||
document.body.classList.add('sticky')
|
document.body.classList.add('sticky')
|
||||||
@@ -97,13 +103,24 @@ export function renderApp (dom, replace) {
|
|||||||
*/
|
*/
|
||||||
export function renderArticle (content) {
|
export function renderArticle (content) {
|
||||||
renderTo('article', content ? markdown(content) : 'not found')
|
renderTo('article', content ? markdown(content) : 'not found')
|
||||||
if (!OPTIONS.sidebar && !OPTIONS.loadSidebar) renderSidebar()
|
if (!__docsify__.loadSidebar) renderSidebar()
|
||||||
|
|
||||||
if (content && typeof Vue !== 'undefined' && typeof Vuep !== 'undefined') {
|
if (content && typeof Vue !== 'undefined') {
|
||||||
const vm = new Vue({ el: 'main' }) // eslint-disable-line
|
CACHE.vm && CACHE.vm.$destroy()
|
||||||
vm.$nextTick(_ => event.scrollActiveSidebar())
|
|
||||||
|
const script = [].slice.call(
|
||||||
|
document.body.querySelectorAll('article>script'))
|
||||||
|
.filter(script => !/template/.test(script.type)
|
||||||
|
)[0]
|
||||||
|
const code = script ? script.innerText.trim() : null
|
||||||
|
|
||||||
|
script && script.remove()
|
||||||
|
CACHE.vm = code
|
||||||
|
? new Function(`return ${code}`)()
|
||||||
|
: new Vue({ el: 'main' }) // eslint-disable-line
|
||||||
|
CACHE.vm && CACHE.vm.$nextTick(_ => event.scrollActiveSidebar())
|
||||||
}
|
}
|
||||||
if (OPTIONS.auto2top) setTimeout(() => event.scroll2Top(OPTIONS.auto2top), 0)
|
if (__docsify__.auto2top) setTimeout(() => event.scroll2Top(__docsify__.auto2top), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,13 +144,11 @@ export function renderSidebar (content) {
|
|||||||
html = markdown(content)
|
html = markdown(content)
|
||||||
// find url tag
|
// find url tag
|
||||||
html = html.match(/<ul[^>]*>([\s\S]+)<\/ul>/g)[0]
|
html = html.match(/<ul[^>]*>([\s\S]+)<\/ul>/g)[0]
|
||||||
} else if (OPTIONS.sidebar) {
|
|
||||||
html = tpl.tree(OPTIONS.sidebar, '<ul>')
|
|
||||||
} else {
|
} else {
|
||||||
html = tpl.tree(genTree(toc, OPTIONS.maxLevel), '<ul>')
|
html = tpl.tree(genTree(toc, __docsify__.maxLevel), '<ul>')
|
||||||
}
|
}
|
||||||
|
|
||||||
html = (OPTIONS.name ? `<h1><a href="${OPTIONS.nameLink}">${OPTIONS.name}</a></h1>` : '') + html
|
html = (__docsify__.name ? `<h1><a href="${__docsify__.nameLink}">${__docsify__.name}</a></h1>` : '') + html
|
||||||
renderTo('aside.sidebar', html)
|
renderTo('aside.sidebar', html)
|
||||||
const target = event.activeLink('aside.sidebar', true)
|
const target = event.activeLink('aside.sidebar', true)
|
||||||
if (target) renderSubSidebar(target)
|
if (target) renderSubSidebar(target)
|
||||||
@@ -143,8 +158,8 @@ export function renderSidebar (content) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function renderSubSidebar (target) {
|
export function renderSubSidebar (target) {
|
||||||
if (!OPTIONS.subMaxLevel) return
|
if (!__docsify__.subMaxLevel) return
|
||||||
target.parentNode.innerHTML += tpl.tree(genTree(toc, OPTIONS.subMaxLevel), '<ul>')
|
target.parentNode.innerHTML += tpl.tree(genTree(toc, __docsify__.subMaxLevel), '<ul>')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,9 +175,12 @@ export function renderCover (content) {
|
|||||||
if (renderCover.rendered) return event.sticky()
|
if (renderCover.rendered) return event.sticky()
|
||||||
|
|
||||||
// render cover
|
// render cover
|
||||||
|
const cacheToc = toc.slice()
|
||||||
let html = markdown(content)
|
let html = markdown(content)
|
||||||
const match = html.trim().match('<p><img[^s]+src="(.*?)"[^a]+alt="(.*?)">([^<]*?)</p>$')
|
const match = html.trim().match('<p><img[^s]+src="(.*?)"[^a]+alt="(.*?)">([^<]*?)</p>$')
|
||||||
|
|
||||||
|
toc = cacheToc.slice()
|
||||||
|
|
||||||
// render background
|
// render background
|
||||||
if (match) {
|
if (match) {
|
||||||
const coverEl = document.querySelector('section.cover')
|
const coverEl = document.querySelector('section.cover')
|
||||||
|
|||||||
@@ -72,9 +72,11 @@ section.cover {
|
|||||||
|
|
||||||
.cover-main p:last-child a {
|
.cover-main p:last-child a {
|
||||||
border-radius: 2em;
|
border-radius: 2em;
|
||||||
border: 1px solid $color-primary;
|
border-width: 1px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: var(--theme-color, $color-primary);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
color: $color-primary;
|
color: var(--theme-color, $color-primary);
|
||||||
font-size: 1.05em;
|
font-size: 1.05em;
|
||||||
letter-spacing: 0.1em;
|
letter-spacing: 0.1em;
|
||||||
padding: 0.75em 2em;
|
padding: 0.75em 2em;
|
||||||
@@ -85,7 +87,7 @@ section.cover {
|
|||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
background-color: $color-primary;
|
background-color: var(--theme-color, $color-primary);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|||||||
@@ -7,8 +7,13 @@
|
|||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.emoji {
|
||||||
|
height: 1.2em;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
.progress {
|
.progress {
|
||||||
background-color: $color-primary;
|
background-color: var(--theme-color, $color-primary);
|
||||||
height: 2px;
|
height: 2px;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
@@ -81,12 +86,12 @@ nav {
|
|||||||
transition: color .3s;
|
transition: color .3s;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: $color-primary;
|
color: var(--theme-color, $color-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
color: $color-primary;
|
color: var(--theme-color, $color-primary);
|
||||||
border-bottom: 2px solid $color-primary;
|
border-bottom: 2px solid var(--theme-color, $color-primary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +103,9 @@ nav {
|
|||||||
ul {
|
ul {
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
background-color: rgba($color-bg, .6);
|
background-color: rgba($color-bg, .6);
|
||||||
border: 1px solid $color-primary;
|
border-width: 1px;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: var(--theme-color, $color-primary);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@@ -155,7 +162,7 @@ nav {
|
|||||||
color: $color-bg;
|
color: $color-bg;
|
||||||
height: 80px;
|
height: 80px;
|
||||||
width: 80px;
|
width: 80px;
|
||||||
fill: $color-primary;
|
fill: var(--theme-color, $color-primary);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,16 +195,7 @@ main {
|
|||||||
transition: transform 250ms ease-out;
|
transition: transform 250ms ease-out;
|
||||||
width: $sidebar-width;
|
width: $sidebar-width;
|
||||||
z-index: 20;
|
z-index: 20;
|
||||||
margin-bottom: 40px;
|
border-right: 1px solid rgba(0, 0, 0, .07);
|
||||||
|
|
||||||
&::after {
|
|
||||||
content: '';
|
|
||||||
position: inherit;
|
|
||||||
left: calc($sidebar-width - 1px);
|
|
||||||
top: 0;
|
|
||||||
height: 100vh;
|
|
||||||
border-right: 1px solid rgba(0, 0, 0, .07);
|
|
||||||
}
|
|
||||||
|
|
||||||
> h1 {
|
> h1 {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@@ -250,7 +248,7 @@ main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
span {
|
span {
|
||||||
background-color: $color-primary;
|
background-color: var(--theme-color, $color-primary);
|
||||||
display: block;
|
display: block;
|
||||||
size: 16px 2px;
|
size: 16px 2px;
|
||||||
margin-bottom: 4px;
|
margin-bottom: 4px;
|
||||||
@@ -287,6 +285,12 @@ body.sticky {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.markdown-section hr {
|
||||||
|
border: none;
|
||||||
|
margin: 2em 0;
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
.markdown-section table {
|
.markdown-section table {
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -348,6 +352,12 @@ body.sticky {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.markdown-section p.warn {
|
||||||
|
padding: 1em;
|
||||||
|
background: rgba($color-primary, 0.1);
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
body.close {
|
body.close {
|
||||||
.sidebar {
|
.sidebar {
|
||||||
transform: translateX(-$sidebar-width);
|
transform: translateX(-$sidebar-width);
|
||||||
@@ -367,15 +377,6 @@ body.close {
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar {
|
|
||||||
margin-bottom: 0;
|
|
||||||
border-right: 1px solid rgba(0, 0, 0, .07);
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
content: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nav {
|
nav {
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ $sidebar-width: 16em;
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.active {
|
li.active {
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
@@ -47,7 +47,7 @@ $sidebar-width: 16em;
|
|||||||
}
|
}
|
||||||
|
|
||||||
.markdown-section a {
|
.markdown-section a {
|
||||||
color: $color-primary;
|
color: var(--theme-color, $color-primary);
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ $sidebar-width: 16em;
|
|||||||
|
|
||||||
.markdown-section blockquote {
|
.markdown-section blockquote {
|
||||||
color: #858585;
|
color: #858585;
|
||||||
border-left: 4px solid $color-primary;
|
border-left: 4px solid var(--theme-color, $color-primary);
|
||||||
margin: 2em 0;
|
margin: 2em 0;
|
||||||
padding-left: 20px;
|
padding-left: 20px;
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -38,7 +38,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ul li.active>a {
|
ul li.active>a {
|
||||||
color: $color-primary;
|
color: var(--theme-color, $color-primary);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.markdown-section a {
|
.markdown-section a {
|
||||||
color: $color-primary;
|
color: var(--theme-color, $color-primary);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ body {
|
|||||||
|
|
||||||
.markdown-section blockquote {
|
.markdown-section blockquote {
|
||||||
color: #858585;
|
color: #858585;
|
||||||
border-left: 4px solid $color-primary;
|
border-left: 4px solid var(--theme-color, $color-primary);
|
||||||
margin: 2em 0;
|
margin: 2em 0;
|
||||||
padding-left: 20px;
|
padding-left: 20px;
|
||||||
}
|
}
|
||||||
@@ -179,7 +179,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.token.string {
|
.token.string {
|
||||||
color: $color-primary;
|
color: var(--theme-color, $color-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.selector {
|
.token.selector {
|
||||||
@@ -201,7 +201,7 @@ body {
|
|||||||
.token.control,
|
.token.control,
|
||||||
.token.directive,
|
.token.directive,
|
||||||
.token.unit {
|
.token.unit {
|
||||||
color: $color-primary;
|
color: var(--theme-color, $color-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.token.keyword {
|
.token.keyword {
|
||||||
|
|||||||
+9
-2
@@ -22,8 +22,8 @@ export function corner (data) {
|
|||||||
/**
|
/**
|
||||||
* Render main content
|
* Render main content
|
||||||
*/
|
*/
|
||||||
export function main (tpl) {
|
export function main () {
|
||||||
const aside = `${tpl}<aside class="sidebar"></aside>`
|
const aside = `${toggle()}<aside class="sidebar"></aside>`
|
||||||
|
|
||||||
return (isMobile() ? `${aside}<main>` : `<main>${aside}`) +
|
return (isMobile() ? `${aside}<main>` : `<main>${aside}`) +
|
||||||
`<section class="content">
|
`<section class="content">
|
||||||
@@ -72,3 +72,10 @@ export function tree (toc, tpl = '') {
|
|||||||
return tpl
|
return tpl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function helper (className, content) {
|
||||||
|
return `<p class="${className}">${content.slice(5).trim()}</p>`
|
||||||
|
}
|
||||||
|
|
||||||
|
export function theme (color) {
|
||||||
|
return `<style>:root{--theme-color: ${color};}</style>`
|
||||||
|
}
|
||||||
|
|||||||
@@ -157,3 +157,10 @@ export const merge = Object.assign || function (to) {
|
|||||||
|
|
||||||
return to
|
return to
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function emojify (text) {
|
||||||
|
return text
|
||||||
|
.replace(/:(\w*?):/ig, '<img class="emoji" src="https://assets-cdn.github.com/images/icons/emoji/$1.png" alt="$1" />')
|
||||||
|
.replace(/__colon__/g, ':')
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user