Compare commits

..
53 Commits
Author SHA1 Message Date
qingwei.li 543cbbce81 -> v2.0.2 2017-02-05 14:50:09 +08:00
qingwei.li 72c34152d4 bump: 2.0.2 2017-02-05 14:50:04 +08:00
qingwei.li 44708554f7 fix: button style in cover page 2017-02-05 14:48:57 +08:00
qingwei.li 6e35f6481a docs: update api 2017-02-05 13:53:36 +08:00
qingwei.li 115c80b2f2 -> v2.0.1 2017-02-05 13:50:36 +08:00
qingwei.li addb34d38a bump: 2.0.1 2017-02-05 13:47:32 +08:00
qingwei.li 1f12009a98 fix border style. 2017-02-05 13:47:03 +08:00
qingwei.li 4abcb02824 -> v2.0.0 2017-02-05 10:27:48 +08:00
qingwei.li d45e325d54 bump 2.0 2017-02-05 10:27:42 +08:00
qingwei.li f2f37eec46 Update version number 2017-02-05 10:26:25 +08:00
qingwei.li fef969f55d clean api 2017-02-05 10:26:25 +08:00
qingwei.li 5cc9f0514c feat: customize the theme color 2017-02-05 10:26:25 +08:00
qingwei.li ae1ad735d5 -> v1.10.5 2017-01-28 11:12:26 +08:00
qingwei.li a35a336d00 bump 1.10.5 2017-01-28 11:12:22 +08:00
qingwei.li 3ec7c89bbb fix initialize the Vue instance 2017-01-28 11:11:58 +08:00
qingwei.li 89f0b1fcbd -> v1.10.4 2017-01-27 15:14:23 +08:00
qingwei.li 6f5bb1a527 bump 1.10.4 2017-01-27 15:14:15 +08:00
qingwei.li 98ec020c7a fix execute script 2017-01-27 15:13:51 +08:00
qingwei.li bb13ddd5df -> v1.10.3 2017-01-27 12:45:42 +08:00
qingwei.li e69efb8954 bump 1.10.3 2017-01-27 12:45:16 +08:00
qingwei.li 0e5f28cf60 Add change log 2017-01-27 12:44:54 +08:00
qingwei.li 7db1f1034a Fix sidebar scroll, fixed #63 2017-01-27 12:44:05 +08:00
qingwei.li b0320416a5 compatible vuep, fixed QingWei-Li/vuep/issues/2 2017-01-27 12:01:36 +08:00
qingwei.li 4a77b8a7f3 -> v1.10.2 2017-01-25 21:39:42 +08:00
qingwei.li 00b13c5e86 bump 1.10.2 2017-01-25 21:39:32 +08:00
qingwei.li 82b7b8226d Fix render emojis again 2017-01-25 21:39:12 +08:00
qingwei.li c9739e71af -> v1.10.1 2017-01-25 21:17:54 +08:00
qingwei.li bda1b76ba5 bump 1.10.1 2017-01-25 21:17:43 +08:00
qingwei.li 11f77cd434 Fix render emojis 2017-01-25 21:16:53 +08:00
qingwei.li 6d42c6b04a -> v1.10.0 2017-01-25 15:08:40 +08:00
qingwei.li 46967e73bf bump 1.10.0 2017-01-25 15:08:28 +08:00
qingwei.li ccdc3c855a Support emoji, closed #61 2017-01-25 15:07:36 +08:00
qingwei.li 7c4b0b7c74 -> v1.9.0 2017-01-24 22:31:44 +08:00
qingwei.li 98d1b19bea bump 1.9.0 2017-01-24 22:31:27 +08:00
cinwell.liandGitHub 0709239c77 1.9 (#62)
* Destroys the vue instance when the route is changed

* Add new doc helper

* Update docs
2017-01-24 22:29:50 +08:00
qingwei.li 73cc43c6bd -> v1.8.0 2017-01-24 11:28:15 +08:00
qingwei.li 9d096b03a4 bump 1.8.0 2017-01-24 11:28:04 +08:00
qingwei.li 2af035ff45 Fix fallback sidebar 2017-01-24 10:18:58 +08:00
qingwei.li 3979f5cd3f Update change log 2017-01-24 10:07:14 +08:00
qingwei.li 9abae495ac Execute script when vue exists. 2017-01-24 10:06:38 +08:00
qingwei.li d179ade7df Using v-pre 2017-01-18 16:35:19 +08:00
qingwei.li d79c7655cd Update license 2017-01-18 16:34:05 +08:00
citycideandcinwell.li af5d2934e4 add Trilogy to showcase list (#58) 2017-01-17 08:05:12 +08:00
Antony Jonesandcinwell.li 129bd4d3a0 Add vudash to list of projects using docsify (#57) 2017-01-15 18:45:32 +08:00
qingwei.li abaf5c0849 -> v1.7.4 2017-01-13 23:33:20 +08:00
qingwei.li 336efb30cb bump 1.7.4 2017-01-13 23:33:04 +08:00
qingwei.li fb8bf89d73 Fix bugs caused by the previous version, fixed #56 2017-01-13 23:32:38 +08:00
qingwei.li 8630591bd2 -> v1.7.3 2017-01-13 23:06:31 +08:00
qingwei.li c47ff83073 bump 1.7.3 2017-01-13 23:06:18 +08:00
cinwell.liandGitHub 69e500bd33 Fix repo (#55)
* Fix option is an empty string

* Fix test

* Add hr style #54

* Tweak hr style
2017-01-13 23:05:05 +08:00
qingwei.li 000a1fcdf0 -> v1.7.2 2017-01-12 21:31:40 +08:00
qingwei.li b84544960f bump 1.7.2 2017-01-12 21:31:22 +08:00
qingwei.li 28a004840d Fix sidebar click event in mobile browser 2017-01-12 21:30:33 +08:00
26 changed files with 533 additions and 296 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
{
"extends": ["vue"],
"globals": {
"XMLHttpRequest": true
"XMLHttpRequest": true,
"__docsify__": true
}
}
+72
View File
@@ -1,3 +1,75 @@
## 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
- Fix sidebar click event in mobile browser.
## 1.7.1
### Bug fixes
- Fix sidebar style in mobile browser.
+1 -1
View File
@@ -1,6 +1,6 @@
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
of this software and associated documentation files (the "Software"), to deal
+9 -2
View File
@@ -22,9 +22,10 @@
- Simple and lightweight (~13kB gzipped)
- Multiple themes
- Not build static html files
- Support emoji :laughing:
## Quick start
Create a `index.html` and using `hash router`.
Create a `index.html`.
index.html
@@ -38,7 +39,7 @@ index.html
<body>
<div id="app"></div>
</body>
<script src="//unpkg.com/docsify" data-router></script>
<script src="//unpkg.com/docsify"></script>
</html>
```
@@ -46,6 +47,10 @@ index.html
- UNPKG [https://unpkg.com/docsify/](https://unpkg.com/docsify/)
- jsDelivr [http://www.jsdelivr.com/projects/docsify](http://www.jsdelivr.com/projects/docsify)
## Browser Support
Modern browsers and Internet Explorer 9+.
## Showcase
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.
- [puck](https://puck.zz173.com/) - A small & magical php framework.
- [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
- [docute](https://github.com/egoist/docute) - 📜 Effortlessly documentation done right
+9 -1
View File
@@ -3,7 +3,15 @@ var cssnano = require('cssnano').process
var resolve = require('path').resolve
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) {
fs.writeFileSync(resolve(__dirname, '../lib/themes/', file), content)
+2 -2
View File
@@ -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">
<link rel="stylesheet" href="/themes/vue.css">
</head>
<body class="">
<body>
<div id="app"></div>
</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>
+59 -65
View File
@@ -20,7 +20,7 @@ Create a `index.html` file
<body>
<div id="app"></div>
</body>
<script src="//unpkg.com/docsify" data-router></script>
<script src="//unpkg.com/docsify"></script>
</html>
```
@@ -160,10 +160,10 @@ window.$docsify = {
### Doc Helpers
#### 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
! Important **information**
!> Important **information**
```
It will be rendered
@@ -174,9 +174,48 @@ It will be rendered
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
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`.
![image](https://cloud.githubusercontent.com/assets/7565692/20647425/de5ab1c2-b4ce-11e6-863a-135868f2f9b4.png)
```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 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)
```
### router
Hash router.
```html
<script src="/lib/docsify.js" data-router></script>
```
```js
window.$docsify = {
router: true
}
```
### auto2top
@@ -384,7 +365,7 @@ window.$docsify = {
### 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
<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:
@@ -449,7 +430,7 @@ window.$docsify = {
}
```
### nameLink
### name-link
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
View File
@@ -1,12 +1,13 @@
![logo](_media/icon.svg)
# docsify <small>1.7.1</small>
# docsify <small>2.0.2</small>
> A magical documentation site generator.
- Simple and lightweight (~13kB gzipped)
- Multiple themes
- Not build static html files
- Support emoji :laughing:
- Multiple themes
[GitHub](https://github.com/QingWei-Li/docsify/)
+1 -3
View File
@@ -18,10 +18,8 @@
<script
src="//unpkg.com/docsify/lib/docsify.min.js"
data-max-level="4"
data-sidebar-toggle
data-coverpage
data-name="docsify"
data-router></script>
data-name="docsify"></script>
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script>
</html>
+65 -66
View File
@@ -25,7 +25,7 @@ mkdir docs && cd docs
<body>
<div id="app"></div>
</body>
<script src="//unpkg.com/docsify" data-router></script>
<script src="//unpkg.com/docsify"></script>
</html>
```
@@ -166,10 +166,10 @@ window.$docsify = {
### 文档助手
#### 内置「提示」语法
感叹号加空格,后面接内容,会渲染成带 tip 类名的段落。
`!>`后面接内容,会渲染成带 tip 类名的段落。
```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` 传入全局变量名。
![image](https://cloud.githubusercontent.com/assets/7565692/20647425/de5ab1c2-b4ce-11e6-863a-135868f2f9b4.png)
```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
读取侧边栏配置文件,如果配置,默认加载当前目录下的 `_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
切换路由时自动跳转到页面顶部
@@ -387,7 +372,7 @@ window.$docsify = {
### homepage
默认情况下网站会将根目录下 `README.md` 作为首页渲染,但是有些时候我们想指定其他文件,甚至想直接将 repo 下的 README 作为首页。你可以这样做(需要设置 `data-router`):
默认情况下网站会将根目录下 `README.md` 作为首页渲染,但是有些时候我们想指定其他文件,甚至想直接将 repo 下的 README 作为首页。
```html
@@ -402,7 +387,7 @@ window.$docsify = {
}
```
### basePath
### base-path
指定加载文档的路径,如果你的 HTML 入口文件和文档是放在不同地方,你可以设置:
@@ -453,7 +438,7 @@ window.$docsify = {
}
```
### nameLink
### name-link
项目名链接,默认为 `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'
}
```
+130 -55
View File
@@ -168,6 +168,12 @@ var merge = Object.assign || function (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
* @link https://buble.surge.sh/
@@ -178,6 +184,8 @@ function scrollActiveSidebar () {
var hoveredOverSidebar = false;
var anchors = document.querySelectorAll('.anchor');
var sidebar = document.querySelector('aside.sidebar');
var sidebarHeight = sidebar.clientHeight;
var nav = {};
var lis = sidebar.querySelectorAll('li');
var active = sidebar.querySelector('li.active');
@@ -216,7 +224,25 @@ function scrollActiveSidebar () {
li.classList.add('active');
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);
@@ -273,9 +299,9 @@ function bindToggle (dom) {
if (isMobile()) {
var sidebar = document.querySelector('aside.sidebar');
document.body.addEventListener('click', function (e) {
if (e.target !== dom && !dom.contains(e.target)) { body.classList.toggle('close'); }
if (sidebar.contains(e.target)) { setTimeout(function () { return activeLink(sidebar, true); }, 0); }
sidebar.addEventListener('click', function () {
body.classList.toggle('close');
setTimeout(function () { return activeLink(sidebar, true); }, 0);
});
}
}
@@ -2421,8 +2447,8 @@ function corner (data) {
/**
* Render main content
*/
function main (tpl) {
var aside = tpl + "<aside class=\"sidebar\"></aside>";
function main () {
var aside = (toggle()) + "<aside class=\"sidebar\"></aside>";
return (isMobile() ? (aside + "<main>") : ("<main>" + aside)) +
"<section class=\"content\">\n <article class=\"markdown-section\"></article>\n </section>\n </main>"
@@ -2463,11 +2489,41 @@ function tree (toc, 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 toc = [];
var CACHE = {};
var TIP_RE = /^!\s/;
var renderTo = function (dom, content) {
dom = typeof dom === 'object' ? dom : document.querySelector(dom);
@@ -2479,11 +2535,8 @@ var renderTo = function (dom, content) {
/**
* init render
* @param {Object} options
*/
function init (options) {
OPTIONS$1 = options;
function init () {
var renderer = new marked.Renderer();
/**
* render anchor tag
@@ -2493,10 +2546,7 @@ function init (options) {
var slug = slugify(text);
var route = '';
if (OPTIONS$1.router) {
route = "#/" + (getRoute());
}
route = "#/" + (getRoute());
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 + ">")
@@ -2505,29 +2555,36 @@ function init (options) {
renderer.code = function (code, lang) {
if ( lang === void 0 ) lang = '';
var hl = prism.highlight(code, prism.languages[lang] || prism.languages.markup)
.replace(/{{/g, '<span>{{</span>');
var hl = prism.highlight(code, prism.languages[lang] || prism.languages.markup);
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) {
if (OPTIONS$1.router && !/:/.test(href)) {
if (!/:/.test(href)) {
href = ("#/" + href).replace(/\/\//g, '/');
}
return ("<a href=\"" + href + "\" title=\"" + (title || '') + "\">" + text + "</a>")
};
renderer.paragraph = function (text) {
var isTip = TIP_RE.test(text);
return isTip ? ("<p class=\"tip\">" + (text.replace(TIP_RE, '')) + "</p>") : ("<p>" + text + "</p>")
if (/^!&gt;/.test(text)) {
return helper('tip', text)
} else if (/^\?&gt;/.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 = OPTIONS$1.markdown.call(this, markdown);
markdown = __docsify__.markdown.call(this, markdown);
} 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) {
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) +
(OPTIONS$1.coverpage ? cover() : '') +
main(OPTIONS$1.sidebarToggle ? toggle() : '');
dom[replace ? 'outerHTML' : 'innerHTML'] = corner(__docsify__.repo) +
(__docsify__.coverpage ? cover() : '') +
main();
document.body.insertBefore(nav, document.body.children[0]);
// theme color
if (__docsify__.themeColor) {
document.head.innerHTML += theme(__docsify__.themeColor);
cssVars();
}
// bind toggle
bindToggle('button.sidebar-toggle');
// bind sticky effect
if (OPTIONS$1.coverpage) {
if (__docsify__.coverpage) {
!isMobile() && window.addEventListener('scroll', sticky);
} else {
document.body.classList.add('sticky');
@@ -2558,13 +2621,24 @@ function renderApp (dom, replace) {
*/
function renderArticle (content) {
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') {
var vm = new Vue({ el: 'main' }); // eslint-disable-line
vm.$nextTick(function (_) { return scrollActiveSidebar(); });
if (content && typeof Vue !== 'undefined') {
CACHE.vm && CACHE.vm.$destroy();
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);
// find url tag
html = html.match(/<ul[^>]*>([\s\S]+)<\/ul>/g)[0];
} else if (OPTIONS$1.sidebar) {
html = tree(OPTIONS$1.sidebar, '<ul>');
} 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);
var target = activeLink('aside.sidebar', true);
if (target) { renderSubSidebar(target); }
@@ -2604,8 +2676,8 @@ function renderSidebar (content) {
}
function renderSubSidebar (target) {
if (!OPTIONS$1.subMaxLevel) { return }
target.parentNode.innerHTML += tree(genTree(toc, OPTIONS$1.subMaxLevel), '<ul>');
if (!__docsify__.subMaxLevel) { return }
target.parentNode.innerHTML += tree(genTree(toc, __docsify__.subMaxLevel), '<ul>');
}
/**
@@ -2621,9 +2693,12 @@ function renderCover (content) {
if (renderCover.rendered) { return sticky() }
// render cover
var cacheToc = toc.slice();
var html = markdown(content);
var match = html.trim().match('<p><img[^s]+src="(.*?)"[^a]+alt="(.*?)">([^<]*?)</p>$');
toc = cacheToc.slice();
// render background
if (match) {
var coverEl = document.querySelector('section.cover');
@@ -2685,16 +2760,14 @@ var OPTIONS = merge({
repo: '',
maxLevel: 6,
subMaxLevel: 0,
sidebar: '',
sidebarToggle: false,
loadSidebar: null,
loadNavbar: null,
router: false,
homepage: 'README.md',
coverpage: '',
basePath: '',
auto2top: false,
name: '',
themeColor: '',
nameLink: window.location.pathname
}, window.$docsify);
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.loadNavbar === true) { OPTIONS.loadNavbar = '_navbar.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
init(OPTIONS);
@@ -2752,11 +2829,10 @@ var mainRender = function (cb) {
if (OPTIONS.coverpage && page !== OPTIONS.homepage) { renderCover(); }
// render sidebar
if (OPTIONS.loadSidebar) {
load(basePath + OPTIONS.loadSidebar)
.then(function (result) {
renderSidebar(result);
cb();
});
var renderSidebar$$1 = function (result) { renderSidebar(result); cb(); };
load(basePath + OPTIONS.loadSidebar).then(renderSidebar$$1,
function (_) { return load(OPTIONS.loadSidebar).then(renderSidebar$$1); });
} else {
cb();
}
@@ -2764,7 +2840,8 @@ var mainRender = function (cb) {
// Render navbar
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
renderApp(dom, replace);
main();
if (OPTIONS.router) {
if (!/^#\//.test(window.location.hash)) { window.location.hash = '#/'; }
window.addEventListener('hashchange', main);
}
if (!/^#\//.test(window.location.hash)) { window.location.hash = '#/'; }
window.addEventListener('hashchange', main);
};
var index = Docsify();
+2 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "docsify",
"version": "1.7.1",
"version": "2.0.2",
"description": "A magical documentation generator.",
"main": "lib/docsify.js",
"files": [
+24 -4
View File
@@ -10,6 +10,8 @@ export function scrollActiveSidebar () {
let hoveredOverSidebar = false
const anchors = document.querySelectorAll('.anchor')
const sidebar = document.querySelector('aside.sidebar')
const sidebarHeight = sidebar.clientHeight
const nav = {}
const lis = sidebar.querySelectorAll('li')
let active = sidebar.querySelector('li.active')
@@ -48,7 +50,25 @@ export function scrollActiveSidebar () {
li.classList.add('active')
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)
@@ -107,9 +127,9 @@ export function bindToggle (dom) {
if (isMobile()) {
const sidebar = document.querySelector('aside.sidebar')
document.body.addEventListener('click', e => {
if (e.target !== dom && !dom.contains(e.target)) body.classList.toggle('close')
if (sidebar.contains(e.target)) setTimeout(() => activeLink(sidebar, true), 0)
sidebar.addEventListener('click', () => {
body.classList.toggle('close')
setTimeout(() => activeLink(sidebar, true), 0)
})
}
}
+14 -14
View File
@@ -7,16 +7,14 @@ const OPTIONS = merge({
repo: '',
maxLevel: 6,
subMaxLevel: 0,
sidebar: '',
sidebarToggle: false,
loadSidebar: null,
loadNavbar: null,
router: false,
homepage: 'README.md',
coverpage: '',
basePath: '',
auto2top: false,
name: '',
themeColor: '',
nameLink: window.location.pathname
}, window.$docsify)
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.loadNavbar === true) OPTIONS.loadNavbar = '_navbar.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
render.init(OPTIONS)
@@ -74,11 +76,10 @@ const mainRender = function (cb) {
if (OPTIONS.coverpage && page !== OPTIONS.homepage) render.renderCover()
// render sidebar
if (OPTIONS.loadSidebar) {
load(basePath + OPTIONS.loadSidebar)
.then(result => {
render.renderSidebar(result)
cb()
})
const renderSidebar = result => { render.renderSidebar(result); cb() }
load(basePath + OPTIONS.loadSidebar).then(renderSidebar,
_ => load(OPTIONS.loadSidebar).then(renderSidebar))
} else {
cb()
}
@@ -86,7 +87,8 @@ const mainRender = function (cb) {
// Render navbar
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.renderApp(dom, replace)
main()
if (OPTIONS.router) {
if (!/^#\//.test(window.location.hash)) window.location.hash = '#/'
window.addEventListener('hashchange', main)
}
if (!/^#\//.test(window.location.hash)) window.location.hash = '#/'
window.addEventListener('hashchange', main)
}
export default Docsify()
+27
View File
@@ -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
View File
@@ -2,13 +2,12 @@ import marked from 'marked'
import Prism from 'prismjs'
import * as tpl from './tpl'
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 toc = []
const CACHE = {}
const TIP_RE = /^!\s/
const renderTo = function (dom, content) {
dom = typeof dom === 'object' ? dom : document.querySelector(dom)
@@ -20,11 +19,8 @@ const renderTo = function (dom, content) {
/**
* init render
* @param {Object} options
*/
export function init (options) {
OPTIONS = options
export function init () {
const renderer = new marked.Renderer()
/**
* render anchor tag
@@ -34,10 +30,7 @@ export function init (options) {
const slug = slugify(text)
let route = ''
if (OPTIONS.router) {
route = `#/${getRoute()}`
}
route = `#/${getRoute()}`
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}>`
@@ -45,28 +38,35 @@ export function init (options) {
// highlight code
renderer.code = function (code, lang = '') {
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) {
if (OPTIONS.router && !/:/.test(href)) {
if (!/:/.test(href)) {
href = `#/${href}`.replace(/\/\//g, '/')
}
return `<a href="${href}" title="${title || ''}">${text}</a>`
}
renderer.paragraph = function (text) {
const isTip = TIP_RE.test(text)
return isTip ? `<p class="tip">${text.replace(TIP_RE, '')}</p>` : `<p>${text}</p>`
if (/^!&gt;/.test(text)) {
return tpl.helper('tip', text)
} else if (/^\?&gt;/.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 = OPTIONS.markdown.call(this, markdown)
markdown = __docsify__.markdown.call(this, markdown)
} 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) {
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) +
(OPTIONS.coverpage ? tpl.cover() : '') +
tpl.main(OPTIONS.sidebarToggle ? tpl.toggle() : '')
dom[replace ? 'outerHTML' : 'innerHTML'] = tpl.corner(__docsify__.repo) +
(__docsify__.coverpage ? tpl.cover() : '') +
tpl.main()
document.body.insertBefore(nav, document.body.children[0])
// theme color
if (__docsify__.themeColor) {
document.head.innerHTML += tpl.theme(__docsify__.themeColor)
polyfill.cssVars()
}
// bind toggle
event.bindToggle('button.sidebar-toggle')
// bind sticky effect
if (OPTIONS.coverpage) {
if (__docsify__.coverpage) {
!isMobile() && window.addEventListener('scroll', event.sticky)
} else {
document.body.classList.add('sticky')
@@ -97,13 +103,24 @@ export function renderApp (dom, replace) {
*/
export function renderArticle (content) {
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') {
const vm = new Vue({ el: 'main' }) // eslint-disable-line
vm.$nextTick(_ => event.scrollActiveSidebar())
if (content && typeof Vue !== 'undefined') {
CACHE.vm && CACHE.vm.$destroy()
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)
// find url tag
html = html.match(/<ul[^>]*>([\s\S]+)<\/ul>/g)[0]
} else if (OPTIONS.sidebar) {
html = tpl.tree(OPTIONS.sidebar, '<ul>')
} 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)
const target = event.activeLink('aside.sidebar', true)
if (target) renderSubSidebar(target)
@@ -143,8 +158,8 @@ export function renderSidebar (content) {
}
export function renderSubSidebar (target) {
if (!OPTIONS.subMaxLevel) return
target.parentNode.innerHTML += tpl.tree(genTree(toc, OPTIONS.subMaxLevel), '<ul>')
if (!__docsify__.subMaxLevel) return
target.parentNode.innerHTML += tpl.tree(genTree(toc, __docsify__.subMaxLevel), '<ul>')
}
/**
@@ -160,9 +175,12 @@ export function renderCover (content) {
if (renderCover.rendered) return event.sticky()
// render cover
const cacheToc = toc.slice()
let html = markdown(content)
const match = html.trim().match('<p><img[^s]+src="(.*?)"[^a]+alt="(.*?)">([^<]*?)</p>$')
toc = cacheToc.slice()
// render background
if (match) {
const coverEl = document.querySelector('section.cover')
+5 -3
View File
@@ -72,9 +72,11 @@ section.cover {
.cover-main p:last-child a {
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;
color: $color-primary;
color: var(--theme-color, $color-primary);
font-size: 1.05em;
letter-spacing: 0.1em;
padding: 0.75em 2em;
@@ -85,7 +87,7 @@ section.cover {
&:last-child {
margin-right: 0;
background-color: $color-primary;
background-color: var(--theme-color, $color-primary);
color: #fff;
&:hover {
+27 -26
View File
@@ -7,8 +7,13 @@
-webkit-font-smoothing: antialiased;
}
.emoji {
height: 1.2em;
vertical-align: middle;
}
.progress {
background-color: $color-primary;
background-color: var(--theme-color, $color-primary);
height: 2px;
left: 0px;
position: fixed;
@@ -81,12 +86,12 @@ nav {
transition: color .3s;
&:hover {
color: $color-primary;
color: var(--theme-color, $color-primary);
}
&.active {
color: $color-primary;
border-bottom: 2px solid $color-primary;
color: var(--theme-color, $color-primary);
border-bottom: 2px solid var(--theme-color, $color-primary);
}
}
@@ -98,7 +103,9 @@ nav {
ul {
border-radius: 2px;
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;
overflow: hidden;
padding: 0;
@@ -155,7 +162,7 @@ nav {
color: $color-bg;
height: 80px;
width: 80px;
fill: $color-primary;
fill: var(--theme-color, $color-primary);
}
}
@@ -188,16 +195,7 @@ main {
transition: transform 250ms ease-out;
width: $sidebar-width;
z-index: 20;
margin-bottom: 40px;
&::after {
content: '';
position: inherit;
left: calc($sidebar-width - 1px);
top: 0;
height: 100vh;
border-right: 1px solid rgba(0, 0, 0, .07);
}
border-right: 1px solid rgba(0, 0, 0, .07);
> h1 {
text-align: center;
@@ -250,7 +248,7 @@ main {
}
span {
background-color: $color-primary;
background-color: var(--theme-color, $color-primary);
display: block;
size: 16px 2px;
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 {
display: block;
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 {
.sidebar {
transform: translateX(-$sidebar-width);
@@ -367,15 +377,6 @@ body.close {
position: fixed;
}
.sidebar {
margin-bottom: 0;
border-right: 1px solid rgba(0, 0, 0, .07);
&::after {
content: none;
}
}
nav {
margin-top: 16px;
}
+3 -3
View File
@@ -28,7 +28,7 @@ $sidebar-width: 16em;
padding: 0;
}
.active {
li.active {
background-color: #eee;
a {
@@ -47,7 +47,7 @@ $sidebar-width: 16em;
}
.markdown-section a {
color: $color-primary;
color: var(--theme-color, $color-primary);
font-weight: 400;
}
@@ -110,7 +110,7 @@ $sidebar-width: 16em;
.markdown-section blockquote {
color: #858585;
border-left: 4px solid $color-primary;
border-left: 4px solid var(--theme-color, $color-primary);
margin: 2em 0;
padding-left: 20px;
}
+5 -5
View File
@@ -38,7 +38,7 @@ body {
}
ul li.active>a {
color: $color-primary;
color: var(--theme-color, $color-primary);
font-weight: 600;
}
}
@@ -54,7 +54,7 @@ body {
}
.markdown-section a {
color: $color-primary;
color: var(--theme-color, $color-primary);
font-weight: 600;
}
@@ -107,7 +107,7 @@ body {
.markdown-section blockquote {
color: #858585;
border-left: 4px solid $color-primary;
border-left: 4px solid var(--theme-color, $color-primary);
margin: 2em 0;
padding-left: 20px;
}
@@ -179,7 +179,7 @@ body {
}
.token.string {
color: $color-primary;
color: var(--theme-color, $color-primary);
}
.token.selector {
@@ -201,7 +201,7 @@ body {
.token.control,
.token.directive,
.token.unit {
color: $color-primary;
color: var(--theme-color, $color-primary);
}
.token.keyword {
+9 -2
View File
@@ -22,8 +22,8 @@ export function corner (data) {
/**
* Render main content
*/
export function main (tpl) {
const aside = `${tpl}<aside class="sidebar"></aside>`
export function main () {
const aside = `${toggle()}<aside class="sidebar"></aside>`
return (isMobile() ? `${aside}<main>` : `<main>${aside}`) +
`<section class="content">
@@ -72,3 +72,10 @@ export function tree (toc, 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>`
}
+7
View File
@@ -157,3 +157,10 @@ export const merge = Object.assign || function (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, ':')
}