- " + (tree(node.children)) + "
" + (content.slice(5).trim()) + "
") +} + +function theme (color) { + return ("") +} + +var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + + + + + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +var marked = createCommonjsModule(function (module, exports) { +/** + * marked - a markdown parser + * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed) + * https://github.com/chjj/marked + */ + +(function() { + +/** + * Block-Level Grammar + */ + +var block = { + newline: /^\n+/, + code: /^( {4}[^\n]+\n*)+/, + fences: noop, + hr: /^( *[-*_]){3,} *(?:\n+|$)/, + heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/, + nptable: noop, + lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/, + blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/, + list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/, + html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/, + def: /^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/, + table: noop, + paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/, + text: /^[^\n]+/ +}; + +block.bullet = /(?:[*+-]|\d+\.)/; +block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/; +block.item = replace(block.item, 'gm') + (/bull/g, block.bullet) + (); + +block.list = replace(block.list) + (/bull/g, block.bullet) + ('hr', '\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))') + ('def', '\\n+(?=' + block.def.source + ')') + (); + +block.blockquote = replace(block.blockquote) + ('def', block.def) + (); + +block._tag = '(?!(?:' + + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code' + + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo' + + '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b'; + +block.html = replace(block.html) + ('comment', //) + ('closed', /<(tag)[\s\S]+?<\/\1>/) + ('closing', /'
+ + (escaped ? code : escape(code, true))
+ + '\n';
+ }
+
+ return ''
+ + (escaped ? code : escape(code, true))
+ + '\n\n';
+};
+
+Renderer.prototype.blockquote = function(quote) {
+ return '\n' + quote + '\n'; +}; + +Renderer.prototype.html = function(html) { + return html; +}; + +Renderer.prototype.heading = function(text, level, raw) { + return '
\n' : '
\n'; +}; + +Renderer.prototype.list = function(body, ordered) { + var type = ordered ? 'ol' : 'ul'; + return '<' + type + '>\n' + body + '' + type + '>\n'; +}; + +Renderer.prototype.listitem = function(text) { + return '
' + text + '
\n'; +}; + +Renderer.prototype.table = function(header, body) { + return '' + text + '';
+};
+
+Renderer.prototype.br = function() {
+ return this.options.xhtml ? '' : '
'; +}; + +Renderer.prototype.del = function(text) { + return '
An error occured:
' + + escape(e.message + '', true) + + ''; + } + throw e; + } +} + +/** + * Options + */ + +marked.options = +marked.setOptions = function(opt) { + merge(marked.defaults, opt); + return marked; +}; + +marked.defaults = { + gfm: true, + tables: true, + breaks: false, + pedantic: false, + sanitize: false, + sanitizer: null, + mangle: true, + smartLists: false, + silent: false, + highlight: null, + langPrefix: 'lang-', + smartypants: false, + headerPrefix: '', + renderer: new Renderer, + xhtml: false +}; + +/** + * Expose + */ + +marked.Parser = Parser; +marked.parser = Parser.parse; + +marked.Renderer = Renderer; + +marked.Lexer = Lexer; +marked.lexer = Lexer.lex; + +marked.InlineLexer = InlineLexer; +marked.inlineLexer = InlineLexer.output; + +marked.parse = marked; + +{ + module.exports = marked; +} + +}).call(function() { + return this || (typeof window !== 'undefined' ? window : commonjsGlobal); +}()); +}); + +var prism = createCommonjsModule(function (module) { +/* ********************************************** + Begin prism-core.js +********************************************** */ + +var _self = (typeof window !== 'undefined') + ? window // if in browser + : ( + (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) + ? self // if in worker + : {} // if in node js + ); + +/** + * Prism: Lightweight, robust, elegant syntax highlighting + * MIT license http://www.opensource.org/licenses/mit-license.php/ + * @author Lea Verou http://lea.verou.me + */ + +var Prism = (function(){ + +// Private helper vars +var lang = /\blang(?:uage)?-(\w+)\b/i; +var uniqueId = 0; + +var _ = _self.Prism = { + util: { + encode: function (tokens) { + if (tokens instanceof Token) { + return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias); + } else if (_.util.type(tokens) === 'Array') { + return tokens.map(_.util.encode); + } else { + return tokens.replace(/&/g, '&').replace(/ text.length) { + // Something went terribly wrong, ABORT, ABORT! + break tokenloop; + } + + if (str instanceof Token) { + continue; + } + + pattern.lastIndex = 0; + + var match = pattern.exec(str), + delNum = 1; + + // Greedy patterns can override/remove up to two previously matched tokens + if (!match && greedy && i != strarr.length - 1) { + pattern.lastIndex = pos; + match = pattern.exec(text); + if (!match) { + break; + } + + var from = match.index + (lookbehind ? match[1].length : 0), + to = match.index + match[0].length, + k = i, + p = pos; + + for (var len = strarr.length; k < len && p < to; ++k) { + p += strarr[k].length; + // Move the index i to the element in strarr that is closest to from + if (from >= p) { + ++i; + pos = p; + } + } + + /* + * If strarr[i] is a Token, then the match starts inside another Token, which is invalid + * If strarr[k - 1] is greedy we are in conflict with another greedy pattern + */ + if (strarr[i] instanceof Token || strarr[k - 1].greedy) { + continue; + } + + // Number of tokens to delete and replace with the new match + delNum = k - i; + str = text.slice(pos, p); + match.index -= pos; + } + + if (!match) { + continue; + } + + if(lookbehind) { + lookbehindLength = match[1].length; + } + + var from = match.index + lookbehindLength, + match = match[0].slice(lookbehindLength), + to = from + match.length, + before = str.slice(0, from), + after = str.slice(to); + + var args = [i, delNum]; + + if (before) { + args.push(before); + } + + var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy); + + args.push(wrapped); + + if (after) { + args.push(after); + } + + Array.prototype.splice.apply(strarr, args); + } + } + } + + return strarr; + }, + + hooks: { + all: {}, + + add: function (name, callback) { + var hooks = _.hooks.all; + + hooks[name] = hooks[name] || []; + + hooks[name].push(callback); + }, + + run: function (name, env) { + var callbacks = _.hooks.all[name]; + + if (!callbacks || !callbacks.length) { + return; + } + + for (var i=0, callback; callback = callbacks[i++];) { + callback(env); + } + } + } +}; + +var Token = _.Token = function(type, content, alias, matchedStr, greedy) { + this.type = type; + this.content = content; + this.alias = alias; + // Copy of the full string this token was created from + this.length = (matchedStr || "").length|0; + this.greedy = !!greedy; +}; + +Token.stringify = function(o, language, parent) { + if (typeof o == 'string') { + return o; + } + + if (_.util.type(o) === 'Array') { + return o.map(function(element) { + return Token.stringify(element, language, o); + }).join(''); + } + + var env = { + type: o.type, + content: Token.stringify(o.content, language, parent), + tag: 'span', + classes: ['token', o.type], + attributes: {}, + language: language, + parent: parent + }; + + if (env.type == 'comment') { + env.attributes['spellcheck'] = 'true'; + } + + if (o.alias) { + var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias]; + Array.prototype.push.apply(env.classes, aliases); + } + + _.hooks.run('wrap', env); + + var attributes = Object.keys(env.attributes).map(function(name) { + return name + '="' + (env.attributes[name] || '').replace(/"/g, '"') + '"'; + }).join(' '); + + return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '' + env.tag + '>'; + +}; + +if (!_self.document) { + if (!_self.addEventListener) { + // in Node.js + return _self.Prism; + } + // In worker + _self.addEventListener('message', function(evt) { + var message = JSON.parse(evt.data), + lang = message.language, + code = message.code, + immediateClose = message.immediateClose; + + _self.postMessage(_.highlight(code, _.languages[lang], lang)); + if (immediateClose) { + _self.close(); + } + }, false); + + return _self.Prism; +} + +//Get current script and highlight +var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop(); + +if (script) { + _.filename = script.src; + + if (document.addEventListener && !script.hasAttribute('data-manual')) { + if(document.readyState !== "loading") { + if (window.requestAnimationFrame) { + window.requestAnimationFrame(_.highlightAll); + } else { + window.setTimeout(_.highlightAll, 16); + } + } + else { + document.addEventListener('DOMContentLoaded', _.highlightAll); + } + } +} + +return _self.Prism; + +})(); + +if ('object' !== 'undefined' && module.exports) { + module.exports = Prism; +} + +// hack for components to work correctly in node.js +if (typeof commonjsGlobal !== 'undefined') { + commonjsGlobal.Prism = Prism; +} + + +/* ********************************************** + Begin prism-markup.js +********************************************** */ + +Prism.languages.markup = { + 'comment': //, + 'prolog': /<\?[\w\W]+?\?>/, + 'doctype': //i, + 'cdata': //i, + 'tag': { + pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i, + inside: { + 'tag': { + pattern: /^<\/?[^\s>\/]+/i, + inside: { + 'punctuation': /^<\/?/, + 'namespace': /^[^\s>\/:]+:/ + } + }, + 'attr-value': { + pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i, + inside: { + 'punctuation': /[=>"']/ + } + }, + 'punctuation': /\/?>/, + 'attr-name': { + pattern: /[^\s>\/]+/, + inside: { + 'namespace': /^[^\s>\/:]+:/ + } + } + + } + }, + 'entity': /?[\da-z]{1,8};/i +}; + +// Plugin to make entity title show the real entity, idea by Roman Komarov +Prism.hooks.add('wrap', function(env) { + + if (env.type === 'entity') { + env.attributes['title'] = env.content.replace(/&/, '&'); + } +}); + +Prism.languages.xml = Prism.languages.markup; +Prism.languages.html = Prism.languages.markup; +Prism.languages.mathml = Prism.languages.markup; +Prism.languages.svg = Prism.languages.markup; + + +/* ********************************************** + Begin prism-css.js +********************************************** */ + +Prism.languages.css = { + 'comment': /\/\*[\w\W]*?\*\//, + 'atrule': { + pattern: /@[\w-]+?.*?(;|(?=\s*\{))/i, + inside: { + 'rule': /@[\w-]+/ + // See rest below + } + }, + 'url': /url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i, + 'selector': /[^\{\}\s][^\{\};]*?(?=\s*\{)/, + 'string': { + pattern: /("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/, + greedy: true + }, + 'property': /(\b|\B)[\w-]+(?=\s*:)/i, + 'important': /\B!important\b/i, + 'function': /[-a-z0-9]+(?=\()/i, + 'punctuation': /[(){};:]/ +}; + +Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css); + +if (Prism.languages.markup) { + Prism.languages.insertBefore('markup', 'tag', { + 'style': { + pattern: /("}function z(e,t){return t={exports:{}},e(t,t.exports),t.exports}function H(e,t){var n=[],r={};return e.forEach(function(e){var i=e.level||1,a=i-1;i>t||(r[a]?r[a].children=(r[a].children||[]).concat(e):n.push(e),r[i]=e)}),n}function R(e){if("string"!=typeof e)return"";var t=e.toLowerCase().trim().replace(/<[^>\d]+>/g,"").replace(Ue,"").replace(/\s/g,"-").replace(/-+/g,"-").replace(/^(\d)/,"_$1"),n=De[t];return n=De.hasOwnProperty(t)?n+1:0,De[t]=n,n&&(t=t+"-"+n),t}function W(e,t){return'
- ]*>([\s\S]+)<\/ul>/g)[0];else{var r=Ye[Xe]||H(Je,t);n=N(r,"
- "+e+" \n"},r.prototype.paragraph=function(e){return"
- linktext -
- just text -
- first -
- second -
- third -
- 1 -
- 2
-
-
- 2 a -
- 2 b -
- - 3 -
- "),Ye[Xe]=r}return n}function U(e,t){if(e){Je[0]&&1===Je[0].level&&Je.shift();var n=Ye[Xe]||H(Je,t);e.parentNode.innerHTML+=N(n,'
- '),Ye[Xe]=n}Je=[]}function G(e){var t=Je.slice(),n=Qe(e);return Je=t.slice(),n}function V(){var e=l(".markdown-section>script").filter(function(e){return!/template/.test(e.type)})[0];if(!e)return!1;var t=e.innerText.trim();return!!t&&void setTimeout(function(e){window.__EXECUTE_RESULT__=new Function(t)()},0)}function X(e){e||(e="not found"),this._renderTo(".markdown-section",e),!this.config.loadSidebar&&this._renderSidebar(),this.config.executeScript===!1||"undefined"==typeof window.Vue||V()?this.config.executeScript&&V():setTimeout(function(e){var t=window.__EXECUTE_RESULT__;t&&t.$destroy&&t.$destroy(),window.__EXECUTE_RESULT__=(new window.Vue).$mount("#main")},0),this.config.auto2top&&T(this.config.auto2top)}function Z(e){var n=o(".app-name-link"),r=e.config.nameLink,i=e.route.path;if(n)if(t(e.config.nameLink))n.setAttribute("href",r);else if("object"==typeof r){var a=Object.keys(r).find(function(e){return i.indexOf(e)>-1});n.setAttribute("href",r[a])}}function Y(e){e._renderTo=function(e,t,n){var r=o(e);r&&(r[n?"outerHTML":"innerHTML"]=t)},e._renderSidebar=function(e){var t=this.config,n=t.maxLevel,r=t.subMaxLevel,i=t.autoHeader,a=t.loadSidebar;this._renderTo(".sidebar-nav",D(e,n));var s=S(".sidebar-nav",!0,!0);if(U(a?s:"",r),this.activeLink=s,E(),i&&s){var l=o("#main"),c=l.children[0];if(c&&"H1"!==c.tagName){var h=u("h1");h.innerText=s.innerText,p(l,h)}}},e._renderNav=function(e){e&&this._renderTo("nav",Qe(e)),S("nav")},e._renderMain=function(e){var t=this;a(this,"beforeEach",e,function(e){var n=t.isHTML?e:Qe(e);a(t,"afterEach",n,function(e){return X.call(t,e)})})},e._renderCover=function(e){var t=o(".cover");if(!e)return void g(t,"remove","show");g(t,"add","show");var n=this.coverIsHTML?e:G(e),r=n.trim().match('
"+a(e.message+"",!0)+"";throw e}}var p={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:l,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:l,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:l,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};p.bullet=/(?:[*+-]|\d+\.)/,p.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,p.item=s(p.item,"gm")(/bull/g,p.bullet)(),p.list=s(p.list)(/bull/g,p.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+p.def.source+")")(),p.blockquote=s(p.blockquote)("def",p.def)(),p._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",p.html=s(p.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/
'+(n?e:a(e,!0))+"\n\n":""+(n?e:a(e,!0))+"\n"},r.prototype.blockquote=function(e){return"\n"+e+"\n"},r.prototype.html=function(e){return e},r.prototype.heading=function(e,t,n){return"
\n":"
\n"},r.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+""+n+">\n"},r.prototype.listitem=function(e){return"
"+e+"
\n"},r.prototype.table=function(e,t){return""+e+""},r.prototype.br=function(){return this.options.xhtml?"":"
"},r.prototype.del=function(e){return"
-
-
-
- `
- const el = Docsify.dom.create('div', html)
- const aside = Docsify.dom.find('aside')
+ `` +
+ '' +
+ ''
+ const el = dom.create('div', html)
+ const aside = dom.find('aside')
- Docsify.dom.toggleClass(el, 'search')
- Docsify.dom.before(aside, el)
+ dom.toggleClass(el, 'search')
+ dom.before(aside, el)
}
-function doSearch(value) {
- const $search = Docsify.dom.find('div.search')
- const $panel = Docsify.dom.find($search, '.results-panel')
- const $clearBtn = Docsify.dom.find($search, '.clear-button')
- const $sidebarNav = Docsify.dom.find('.sidebar-nav')
- const $appName = Docsify.dom.find('.app-name')
-
- if (!value) {
- $panel.classList.remove('show')
- $clearBtn.classList.remove('show')
- $panel.innerHTML = ''
-
- if (options.hideOtherSidebarContent) {
- $sidebarNav.classList.remove('hide')
- $appName.classList.remove('hide')
+function bindEvents () {
+ const $search = dom.find('div.search')
+ const $input = dom.find($search, 'input')
+ const $panel = dom.find($search, '.results-panel')
+ const doSearch = function (value) {
+ if (!value) {
+ $panel.classList.remove('show')
+ $panel.innerHTML = ''
+ return
}
- return
- }
- const matchs = search(value)
+ const matchs = search(value)
- let html = ''
- matchs.forEach(post => {
- html += `
-
-
-
-
-
${post.title}
-${post.content}
- + let html = '' + matchs.forEach(post => { + html += `
+
`
- })
+ })
- $panel.classList.add('show')
- $clearBtn.classList.add('show')
- $panel.innerHTML = html || `${post.title}
+${post.content}
${NO_DATA_TEXT}
` - if (options.hideOtherSidebarContent) { - $sidebarNav.classList.add('hide') - $appName.classList.add('hide') + $panel.classList.add('show') + $panel.innerHTML = html || `${NO_DATA_TEXT}
` } -} - -function bindEvents() { - const $search = Docsify.dom.find('div.search') - const $input = Docsify.dom.find($search, 'input') - const $inputWrap = Docsify.dom.find($search, '.input-wrap') let timeId // Prevent to Fold sidebar - Docsify.dom.on( - $search, - 'click', - e => e.target.tagName !== 'A' && e.stopPropagation() - ) - Docsify.dom.on($input, 'input', e => { + dom.on($search, 'click', + e => e.target.tagName !== 'A' && e.stopPropagation()) + dom.on($input, 'input', e => { clearTimeout(timeId) timeId = setTimeout(_ => doSearch(e.target.value.trim()), 100) }) - Docsify.dom.on($inputWrap, 'click', e => { - // Click input outside - if (e.target.tagName !== 'INPUT') { - $input.value = '' - doSearch() - } - }) } -function updatePlaceholder(text, path) { - const $input = Docsify.dom.getNode('.search input[type="search"]') +function updatePlaceholder (text, path) { + const $input = dom.getNode('.search input[type="search"]') - if (!$input) { - return - } if (typeof text === 'string') { $input.placeholder = text } else { - const match = Object.keys(text).filter(key => path.indexOf(key) > -1)[0] + const match = Object.keys(text).find(key => path.indexOf(key) > -1) $input.placeholder = text[match] } } -function updateNoData(text, path) { +function updateNoData (text, path) { if (typeof text === 'string') { NO_DATA_TEXT = text } else { - const match = Object.keys(text).filter(key => path.indexOf(key) > -1)[0] + const match = Object.keys(text).find(key => path.indexOf(key) > -1) NO_DATA_TEXT = text[match] } } -function updateOptions(opts) { - options = opts -} - -export function init(opts, vm) { - const keywords = vm.router.parse().query.s - - updateOptions(opts) +export function init (opts) { + dom = Docsify.dom style() - tpl(keywords) + tpl(opts) bindEvents() - keywords && setTimeout(_ => doSearch(keywords), 500) } -export function update(opts, vm) { - updateOptions(opts) +export function update (opts, vm) { updatePlaceholder(opts.placeholder, vm.route.path) updateNoData(opts.noData, vm.route.path) } + diff --git a/src/plugins/search/index.js b/src/plugins/search/index.js index bbd3af6..6b9d3e1 100644 --- a/src/plugins/search/index.js +++ b/src/plugins/search/index.js @@ -1,18 +1,15 @@ -import {init as initComponet, update as updateComponent} from './component' -import {init as initSearch} from './search' +import { init as initComponet, update as updateComponent } from './component' +import { init as initSearch } from './search' const CONFIG = { placeholder: 'Type to search', noData: 'No Results!', paths: 'auto', - depth: 2, - maxAge: 86400000, // 1 day - hideOtherSidebarContent: false, - namespace: undefined + maxAge: 86400000 // 1 day } const install = function (hook, vm) { - const {util} = Docsify + const util = Docsify.util const opts = vm.config.search || CONFIG if (Array.isArray(opts)) { @@ -22,15 +19,12 @@ const install = function (hook, vm) { CONFIG.maxAge = util.isPrimitive(opts.maxAge) ? opts.maxAge : CONFIG.maxAge CONFIG.placeholder = opts.placeholder || CONFIG.placeholder CONFIG.noData = opts.noData || CONFIG.noData - CONFIG.depth = opts.depth || CONFIG.depth - CONFIG.hideOtherSidebarContent = opts.hideOtherSidebarContent || CONFIG.hideOtherSidebarContent - CONFIG.namespace = opts.namespace || CONFIG.namespace } const isAuto = CONFIG.paths === 'auto' hook.mounted(_ => { - initComponet(CONFIG, vm) + initComponet(CONFIG) !isAuto && initSearch(CONFIG, vm) }) hook.doneEach(_ => { @@ -39,4 +33,4 @@ const install = function (hook, vm) { }) } -$docsify.plugins = [].concat(install, $docsify.plugins) +window.$docsify.plugins = [].concat(install, window.$docsify.plugins) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 2c9febf..fcdbd56 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -1,18 +1,7 @@ let INDEXS = {} +let helper -const LOCAL_STORAGE = { - EXPIRE_KEY: 'docsify.search.expires', - INDEX_KEY: 'docsify.search.index' -} - -function resolveExpireKey(namespace) { - return namespace ? `${LOCAL_STORAGE.EXPIRE_KEY}/${namespace}` : LOCAL_STORAGE.EXPIRE_KEY -} -function resolveIndexKey(namespace) { - return namespace ? `${LOCAL_STORAGE.INDEX_KEY}/${namespace}` : LOCAL_STORAGE.INDEX_KEY -} - -function escapeHtml(string) { +function escapeHtml (string) { const entityMap = { '&': '&', '<': '<', @@ -22,54 +11,54 @@ function escapeHtml(string) { '/': '/' } - return String(string).replace(/[&<>"'/]/g, s => entityMap[s]) + return String(string).replace(/[&<>"'\/]/g, s => entityMap[s]) } -function getAllPaths(router) { +function getAllPaths () { const paths = [] - Docsify.dom.findAll('.sidebar-nav a:not(.section-link):not([data-nosearch])').forEach(node => { - const href = node.href - const originHref = node.getAttribute('href') - const path = router.parse(href).path + helper.dom.findAll('a:not([data-nosearch])') + .map(node => { + const href = node.href + const originHref = node.getAttribute('href') + const path = helper.route.parse(href).path - if ( - path && - paths.indexOf(path) === -1 && - !Docsify.util.isAbsolutePath(originHref) - ) { - paths.push(path) - } - }) + if (path && + paths.indexOf(path) === -1 && + !helper.route.isAbsolutePath(originHref)) { + paths.push(path) + } + }) return paths } -function saveData(maxAge, expireKey, indexKey) { - localStorage.setItem(expireKey, Date.now() + maxAge) - localStorage.setItem(indexKey, JSON.stringify(INDEXS)) +function saveData (maxAge) { + localStorage.setItem('docsify.search.expires', Date.now() + maxAge) + localStorage.setItem('docsify.search.index', JSON.stringify(INDEXS)) } -export function genIndex(path, content = '', router, depth) { +export function genIndex (path, content = '') { const tokens = window.marked.lexer(content) const slugify = window.Docsify.slugify + const toURL = Docsify.route.toURL const index = {} let slug tokens.forEach(token => { - if (token.type === 'heading' && token.depth <= depth) { - slug = router.toURL(path, {id: slugify(token.text)}) - index[slug] = {slug, title: token.text, body: ''} + if (token.type === 'heading' && token.depth <= 2) { + slug = toURL(path, { id: slugify(token.text) }) + index[slug] = { slug, title: token.text, body: '' } } else { - if (!slug) { - return - } + if (!slug) return if (!index[slug]) { - index[slug] = {slug, title: '', body: ''} - } else if (index[slug].body) { - index[slug].body += '\n' + (token.text || '') + index[slug] = { slug, title: '', body: '' } } else { - index[slug].body = token.text + if (index[slug].body) { + index[slug].body += '\n' + (token.text || '') + } else { + index[slug].body = token.text + } } } }) @@ -77,49 +66,37 @@ export function genIndex(path, content = '', router, depth) { return index } -/** - * @param {String} query - * @returns {Array} - */ -export function search(query) { +export function search (keywords) { const matchingResults = [] let data = [] Object.keys(INDEXS).forEach(key => { data = data.concat(Object.keys(INDEXS[key]).map(page => INDEXS[key][page])) }) - query = query.trim() - let keywords = query.split(/[\s\-,\\/]+/) - if (keywords.length !== 1) { - keywords = [].concat(query, keywords) - } + keywords = keywords.trim().split(/[\s\-\,\\/]+/) for (let i = 0; i < data.length; i++) { const post = data[i] - let matchesScore = 0 + let isMatch = false let resultStr = '' const postTitle = post.title && post.title.trim() const postContent = post.body && post.body.trim() const postUrl = post.slug || '' - if (postTitle) { - keywords.forEach( keyword => { - // From https://github.com/sindresorhus/escape-string-regexp - const regEx = new RegExp( - keyword.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'), - 'gi' - ); + if (postTitle && postContent) { + keywords.forEach((keyword, i) => { + const regEx = new RegExp(keyword, 'gi') let indexTitle = -1 let indexContent = -1 - indexTitle = postTitle ? postTitle.search(regEx) : -1 - indexContent = postContent ? postContent.search(regEx) : -1 + indexTitle = postTitle && postTitle.search(regEx) + indexContent = postContent && postContent.search(regEx) - if (indexTitle >= 0 || indexContent >= 0) { - matchesScore += indexTitle >= 0 ? 3 : indexContent >= 0 ? 2 : 0; - if (indexContent < 0) { - indexContent = 0 - } + if (indexTitle < 0 && indexContent < 0) { + isMatch = false + } else { + isMatch = true + if (indexContent < 0) indexContent = 0 let start = 0 let end = 0 @@ -127,27 +104,23 @@ export function search(query) { start = indexContent < 11 ? 0 : indexContent - 10 end = start === 0 ? 70 : indexContent + keyword.length + 60 - if (end > postContent.length) { - end = postContent.length - } + if (end > postContent.length) end = postContent.length - const matchContent = - '...' + + const matchContent = '...' + escapeHtml(postContent) .substring(start, end) .replace(regEx, `${keyword}`) + - '...' + '...' resultStr += matchContent } }) - if (matchesScore > 0) { + if (isMatch) { const matchingPost = { title: escapeHtml(postTitle), - content: postContent ? resultStr : '', - url: postUrl, - score: matchesScore + content: resultStr, + url: postUrl } matchingResults.push(matchingPost) @@ -155,18 +128,16 @@ export function search(query) { } } - return matchingResults.sort((r1, r2) => r2.score - r1.score); + return matchingResults } -export function init(config, vm) { +export function init (config, vm) { + helper = Docsify + const isAuto = config.paths === 'auto' + const isExpired = localStorage.getItem('docsify.search.expires') < Date.now() - const expireKey = resolveExpireKey(config.namespace) - const indexKey = resolveIndexKey(config.namespace) - - const isExpired = localStorage.getItem(expireKey) < Date.now() - - INDEXS = JSON.parse(localStorage.getItem(indexKey)) + INDEXS = JSON.parse(localStorage.getItem('docsify.search.index')) if (isExpired) { INDEXS = {} @@ -174,20 +145,19 @@ export function init(config, vm) { return } - const paths = isAuto ? getAllPaths(vm.router) : config.paths + const paths = isAuto ? getAllPaths() : config.paths const len = paths.length let count = 0 paths.forEach(path => { - if (INDEXS[path]) { - return count++ - } + if (INDEXS[path]) return count++ - Docsify - .get(vm.router.getFile(path), false, vm.config.requestHeaders) + helper + .get(vm.$getFile(path)) .then(result => { - INDEXS[path] = genIndex(path, result, vm.router, config.depth) - len === ++count && saveData(config.maxAge, expireKey, indexKey) + INDEXS[path] = genIndex(path, result) + len === ++count && saveData(config.maxAge) }) }) } + diff --git a/src/plugins/zoom-image.js b/src/plugins/zoom-image.js index faf92e1..15e6435 100644 --- a/src/plugins/zoom-image.js +++ b/src/plugins/zoom-image.js @@ -1,20 +1,22 @@ -import mediumZoom from 'medium-zoom' +import zoom from 'zoom-image' +import style from 'zoom-image/css/zoom-image.css' -const matchesSelector = Element.prototype.matches || Element.prototype.webkitMatchesSelector || Element.prototype.msMatchesSelector +function install (hook) { + const dom = Docsify.dom + let destroys -function install(hook) { - let zoom + // add style + dom.appendTo(dom.head, dom.create('style', style)) hook.doneEach(_ => { - let elms = Array.apply(null, document.querySelectorAll('.markdown-section img:not(.emoji):not([data-no-zoom])')) + const images = dom.findAll('img:not(.emoji)') - elms = elms.filter(elm => matchesSelector.call(elm, 'a img') === false) - - if (zoom) { - zoom.detach() + if (Array.isArray(destroys) && destroys.length) { + destroys.forEach(o => o()) + destroys = [] } - zoom = mediumZoom(elms) + destroys = images.map(zoom) }) } diff --git a/src/themes/basic/_coverpage.css b/src/themes/basic/_coverpage.css new file mode 100644 index 0000000..9d5aa7f --- /dev/null +++ b/src/themes/basic/_coverpage.css @@ -0,0 +1,112 @@ +section.cover { + align-items: center; + background-position: center center; + background-repeat: no-repeat; + background-size: cover; + height: 100vh; + display: none; + + &.show { + display: flex; + } + + &.has-mask .mask { + background-color: $color-bg; + opacity: .8; + position: absolute; + size: 100%; + } + + .cover-main { + flex: 1; + margin: -20px 16px 0; + text-align: center; + z-index: 1; + } + + a { + color: inherit; + text-decoration: none; + + &:hover { + text-decoration: none; + } + } + + p { + line-height: 1.5rem; + margin: 1em 0; + } + + h1 { + color: inherit; + font-size: 2.5rem; + font-weight: 300; + margin: .625rem 0 2.5rem; + position: relative; + text-align: center; + + a { + display: block; + } + + small { + bottom: -.4375rem; + font-size: 1rem; + position: absolute; + } + } + + blockquote { + font-size: 1.5rem; + text-align: center; + } + + ul { + line-height: 1.8; + list-style-type: none; + margin: 1em auto; + max-width: 500px; + padding: 0; + } + + .cover-main > p:last-child a { + border-color: var(--theme-color, $color-primary); + border-radius: 2em; + border-style: solid; + border-width: 1px; + box-sizing: border-box; + color: var(--theme-color, $color-primary); + display: inline-block; + font-size: 1.05em; + letter-spacing: 0.1em; + margin-right: 1em; + padding: 0.75em 2em; + text-decoration: none; + transition: all 0.15s ease; + + &:last-child { + background-color: var(--theme-color, $color-primary); + color: #fff; + margin-right: 0; + + &:hover { + color: inherit; + opacity: .8; + } + } + + &:hover { + color: inherit; + } + } + + blockquote > p > a { + border-bottom: 2px solid var(--theme-color, $color-primary); + transition: color .3s; + + &:hover { + color: var(--theme-color, $color-primary); + } + } +} diff --git a/src/themes/basic/_coverpage.styl b/src/themes/basic/_coverpage.styl deleted file mode 100644 index 0014932..0000000 --- a/src/themes/basic/_coverpage.styl +++ /dev/null @@ -1,95 +0,0 @@ -section.cover - align-items center - background-position center center - background-repeat no-repeat - background-size cover - height 100vh - display none - - &.show - display flex - - &.has-mask .mask - background-color $color-bg - opacity 0.8 - position absolute - top 0 - height 100% - width 100% - - .cover-main - flex 1 - margin -20px 16px 0 - text-align center - z-index 1 - - a - color inherit - text-decoration none - - &:hover - text-decoration none - - p - line-height 1.5rem - margin 1em 0 - - h1 - color inherit - font-size 2.5rem - font-weight 300 - margin 0.625rem 0 2.5rem - position relative - text-align center - - a - display block - - small - bottom -0.4375rem - font-size 1rem - position absolute - - blockquote - font-size 1.5rem - text-align center - - ul - line-height 1.8 - list-style-type none - margin 1em auto - max-width 500px - padding 0 - - .cover-main > p:last-child a - border-color var(--theme-color, $color-primary) - border-radius 2rem - border-style solid - border-width 1px - box-sizing border-box - color var(--theme-color, $color-primary) - display inline-block - font-size 1.05rem - letter-spacing 0.1rem - margin 0.5rem 1rem - padding 0.75em 2rem - text-decoration none - transition all 0.15s ease - - &:last-child - background-color var(--theme-color, $color-primary) - color #fff - - &:hover - color inherit - opacity 0.8 - - &:hover - color inherit - - blockquote > p > a - border-bottom 2px solid var(--theme-color, $color-primary) - transition color 0.3s - - &:hover - color var(--theme-color, $color-primary) diff --git a/src/themes/basic/_layout.css b/src/themes/basic/_layout.css new file mode 100644 index 0000000..e859303 --- /dev/null +++ b/src/themes/basic/_layout.css @@ -0,0 +1,501 @@ +* { + -webkit-font-smoothing: antialiased; + -webkit-overflow-scrolling: touch; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); + -webkit-text-size-adjust: none; + -webkit-touch-callout: none; + box-sizing: border-box; +} + +body:not(.ready) { + overflow: hidden; + + [data-cloak], nav { + display: none; + } +} + +div#app { + font-size: 30px; + font-weight: lighter; + margin: 40vh auto; + text-align: center; + + &:empty::before { + content: "Loading..."; + } +} + +.emoji { + height: 1.2em; + vertical-align: middle; +} + +.progress { + background-color: var(--theme-color, $color-primary); + height: 2px; + left: 0px; + position: fixed; + right: 0px; + top: 0px; + transition: width 0.2s, opacity 0.4s; + width: 0%; + z-index: 999999; +} + +.search a:hover { + color: var(--theme-color, $color-primary); +} + +.search .search-keyword { + color: var(--theme-color, $color-primary); + font-style: normal; +} + +html, body { + height: 100%; +} + +body { + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + color: $color-text; + font-family: 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif; + font-size: 15px; + letter-spacing: 0; + margin: 0; + overflow-x: hidden; +} + +img { + max-width: 100%; +} + +kbd { + border: solid 1px #ccc; + border-radius: 3px; + display: inline-block; + font-size: 12px !important; + line-height: 12px; + margin-bottom : 3px; + padding: 3px 5px; + vertical-align: middle; +} + +/* navbar */ +nav.app-nav { + left: 0; + margin: 25px 60px 0 0; + position: absolute; + right: 0; + text-align: right; + z-index: 10; + + &.no-badge { + margin-right: 25px; + } + + p { + margin: 0; + } + + >a { + margin: 0 1em; + padding: 5px 0; + } + + ul, li { + display: inline-block; + list-style: none; + margin: 0; + } + + a { + color: inherit; + font-size: 16px; + text-decoration: none; + transition: color .3s; + + &:hover { + color: var(--theme-color, $color-primary); + } + + &.active { + border-bottom: 2px solid var(--theme-color, $color-primary); + color: var(--theme-color, $color-primary); + } + } + + /* navbar dropdown */ + li { + display: inline-block; + margin: 0 1em; + padding: 5px 0; + position: relative; + + ul { + background-color: #fff; + border: 1px solid #ddd; + border-bottom-color: #ccc; + border-radius: 4px; + box-sizing: border-box; + display: none; + max-height: calc(100vh - 61px); + overflow-y: scroll; + padding: 10px 0; + position: absolute; + right: -15px; + text-align: left; + top: 100%; + white-space: nowrap; + + li { + display: block; + font-size: 14px; + line-height: 1em; + margin: 0; + margin: 8px 14px; + white-space: nowrap; + } + + a { + display: block; + font-size: inherit; + margin: 0; + padding: 0; + + &.active { + border-bottom: 0; + } + } + } + + &:hover ul { + display: block; + } + } +} + +/* github corner */ +.github-corner { + border-bottom: 0; + position: fixed; + right: 0; + text-decoration: none; + top: 0; + z-index: 1; + + &:hover .octo-arm { + animation:octocat-wave 560ms ease-in-out; + } + + svg { + color: $color-bg; + fill: var(--theme-color, $color-primary); + height: 80px; + width: 80px; + } +} + +/* main */ +main { + display: block; + position: relative; + size: 100vw 100%; +} + +.anchor { + display: inline-block; + text-decoration: none; + transition: all .3s; + + span { + color: $color-text; + } + + &:hover { + text-decoration: underline; + } +} + +/* sidebar */ +.sidebar { + border-right: 1px solid rgba(0, 0, 0, .07); + overflow-y: auto; + padding: 40px 0; + position: absolute 0 * 0 0; + transition: transform 250ms ease-out; + width: $sidebar-width; + z-index: 20; + + > h1 { + margin: 0 auto 1em; + font-size: 1.5em; + font-weight: 300; + text-align: center; + + a { + color: inherit; + text-decoration: none; + } + } + + ul { + margin: 0; + padding: 0; + } + + li>p { + font-weight: 700; + margin: 0; + } + + ul, ul li { + list-style: none; + } + + ul li a { + border-bottom: none; + display: block; + } + + ul li ul { + padding-left: 20px; + } + + &::-webkit-scrollbar { + width: 4px; + } + + &::-webkit-scrollbar-thumb { + background: transparent; + border-radius: 4px; + } + + &:hover::-webkit-scrollbar-thumb { + background: rgba(136, 136, 136, 0.4); + } + + &:hover::-webkit-scrollbar-track { + background: rgba(136, 136, 136, 0.1); + } +} + +/* sidebar toggle */ +.sidebar-toggle { + background-color: transparent; + background-color: rgba($color-bg, .8); + border: 0; + outline: none; + outline: none; + padding: 10px; + position: absolute * * 0 0; + text-align: center; + transition: opacity .3s; + width: 30px; + width: calc($sidebar-width - 16px); + z-index: 30; + + .sidebar-toggle-button:hover { + opacity: .4; + } + + span { + background-color: var(--theme-color, $color-primary); + display: block; + margin-bottom: 4px; + size: 16px 2px; + } +} + +body.sticky { + .sidebar, .sidebar-toggle { + position: fixed; + } +} + +/* main content */ +.content { + padding-top: 20px; + position: absolute 0 0 0 $sidebar-width; + transition: left 250ms ease; +} + +/* markdown content found on pages */ +.markdown-section { + margin: 0 auto; + max-width: 800px; + padding: 20px 15px 40px 15px; + position: relative; + + > * { + box-sizing: border-box; + font-size: inherit; + } + + >:first-child { + margin-top: 0!important; + } +} + +.markdown-section hr { + border: none; + border-bottom: 1px solid #eee; + margin: 2em 0; +} + +.markdown-section table { + border-collapse: collapse; + border-spacing: 0; + display: block; + margin-bottom: 1em; + overflow: auto; + width: 100%; +} + +.markdown-section th { + border: 1px solid #ddd; + font-weight: bold; + padding: 6px 13px; +} + +.markdown-section td { + border: 1px solid #ddd; + padding: 6px 13px; +} + +.markdown-section tr { + border-top: 1px solid #ccc; + &:nth-child(2n) { + background-color: #f8f8f8; + } +} + +.markdown-section p.tip { + background-color: #f8f8f8; + border-bottom-right-radius: 2px; + border-left: 4px solid #f66; + border-top-right-radius: 2px; + margin: 2em 0; + padding: 12px 24px 12px 30px; + position: relative; + + &:before { + background-color: #f66; + border-radius: 100%; + color: $color-bg; + content: "!"; + font-family: 'Dosis', 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif; + font-size: 14px; + font-weight: bold; + left: -12px; + line-height: 20px; + position: absolute; + size: 20px; + text-align: center; + top: 14px; + } + + code { + background-color: #efefef; + } + + em { + color: $color-text; + } +} + +.markdown-section p.warn { + background: rgba($color-primary, 0.1); + border-radius: 2px; + padding: 1em; +} + +body.close { + .sidebar { + transform: translateX(-$sidebar-width); + } + + .sidebar-toggle { + width: auto; + } + + .content { + left: 0; + } +} + +@media (max-width: 600px) { + .github-corner, .sidebar-toggle, .sidebar { + position: fixed; + } + + nav { + margin-top: 16px; + } + + nav li ul { + top: 30px; + } + + main { + height: auto; + overflow-x: hidden; + } + + .sidebar { + left: -$sidebar-width; + transition: transform 250ms ease-out; + } + + .content { + left: 0; + max-width: 100vw; + position: static; + transition: transform 250ms ease; + } + + nav, .github-corner { + transition: transform 250ms ease-out; + } + + .sidebar-toggle { + background-color: transparent; + width: auto; + } + + body.close { + .sidebar { + transform: translateX($sidebar-width); + } + + .sidebar-toggle { + background-color: rgba($color-bg, .8); + transition: 1s background-color; + width: calc($sidebar-width - 16px); + } + + .content { + transform: translateX($sidebar-width); + } + + nav, .github-corner { + display: none; + } + } + + .github-corner { + &:hover .octo-arm { + animation: none; + } + .octo-arm { + animation: octocat-wave 560ms ease-in-out; + } + } +} + +@keyframes octocat-wave { + 0%,100% { transform: rotate(0); } + 20%,60% { transform: rotate(-25deg); } + 40%,80% { transform: rotate(10deg); } +} diff --git a/src/themes/basic/_layout.styl b/src/themes/basic/_layout.styl deleted file mode 100644 index 387fd79..0000000 --- a/src/themes/basic/_layout.styl +++ /dev/null @@ -1,470 +0,0 @@ -* - -webkit-font-smoothing antialiased - -webkit-overflow-scrolling touch - -webkit-tap-highlight-color rgba(0, 0, 0, 0) - -webkit-text-size-adjust none - -webkit-touch-callout none - box-sizing border-box - -body:not(.ready) - overflow hidden - - [data-cloak], .app-nav, > nav - display none - -div#app - font-size 30px - font-weight lighter - margin 40vh auto - text-align center - - &:empty::before - content 'Loading...' - -.emoji - height 1.2rem - vertical-align middle - -.progress - background-color var(--theme-color, $color-primary) - height 2px - left 0px - position fixed - right 0px - top 0px - transition width 0.2s, opacity 0.4s - width 0% - z-index 999999 - -.search a:hover - color var(--theme-color, $color-primary) - -.search .search-keyword - color var(--theme-color, $color-primary) - font-style normal - font-weight bold - -html, body - height 100% - -body - -moz-osx-font-smoothing grayscale - -webkit-font-smoothing antialiased - color $color-text - font-family 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif - font-size 15px - letter-spacing 0 - margin 0 - overflow-x hidden - -img - max-width 100% - -a[disabled] - cursor not-allowed - opacity 0.6 - -kbd - border solid 1px #ccc - border-radius 3px - display inline-block - font-size 12px !important - line-height 12px - margin-bottom 3px - padding 3px 5px - vertical-align middle - -li input[type='checkbox'] - margin 0 0.2em 0.25em 0 - vertical-align middle - -/* navbar */ -.app-nav - margin 25px 60px 0 0 - position absolute - right 0 - text-align right - z-index 10 - - &.no-badge - margin-right 25px - - p - margin 0 - - > a - margin 0 1rem - padding 5px 0 - - ul, li - display inline-block - list-style none - margin 0 - - a - color inherit - font-size 16px - text-decoration none - transition color 0.3s - - &:hover - color var(--theme-color, $color-primary) - - &.active - border-bottom 2px solid var(--theme-color, $color-primary) - color var(--theme-color, $color-primary) - - /* navbar dropdown */ - li - display inline-block - margin 0 1rem - padding 5px 0 - position relative - - ul - background-color #fff - border 1px solid #ddd - border-bottom-color #ccc - border-radius 4px - box-sizing border-box - display none - max-height calc(100vh - 61px) - overflow-y auto - padding 10px 0 - position absolute - right -15px - text-align left - top 100% - white-space nowrap - - li - display block - font-size 14px - line-height 1rem - margin 0 - margin 8px 14px - white-space nowrap - - a - display block - font-size inherit - margin 0 - padding 0 - - &.active - border-bottom 0 - - &:hover ul - display block - -/* github corner */ -.github-corner - border-bottom 0 - position fixed - right 0 - text-decoration none - top 0 - z-index 1 - - &:hover .octo-arm - animation octocat-wave 560ms ease-in-out - - svg - color $color-bg - fill var(--theme-color, $color-primary) - height 80px - width 80px - -/* main */ -main - display block - position relative - width 100vw - height 100% - z-index 0 - -main.hidden - display none - -.anchor - display inline-block - text-decoration none - transition all 0.3s - - span - color $color-text - - &:hover - text-decoration underline - -/* sidebar */ -.sidebar - border-right 1px solid rgba(0, 0, 0, 0.07) - overflow-y auto - padding 40px 0 0 - position absolute - top 0 - bottom 0 - left 0 - transition transform 250ms ease-out - width $sidebar-width - z-index 20 - - > h1 - margin 0 auto 1rem - font-size 1.5rem - font-weight 300 - text-align center - - a - color inherit - text-decoration none - - .app-nav - display block - position static - - .sidebar-nav - line-height 2em - padding-bottom 40px - - li.collapse - .app-sub-sidebar - display none - - ul - margin 0 0 0 15px - padding 0 - - li > p - font-weight 700 - margin 0 - - ul, ul li - list-style none - - ul li a - border-bottom none - display block - - ul li ul - padding-left 20px - - &::-webkit-scrollbar - width 4px - - &::-webkit-scrollbar-thumb - background transparent - border-radius 4px - - &:hover::-webkit-scrollbar-thumb - background rgba(136, 136, 136, 0.4) - - &:hover::-webkit-scrollbar-track - background rgba(136, 136, 136, 0.1) - -/* sidebar toggle */ -.sidebar-toggle - background-color transparent - background-color rgba($color-bg, 0.8) - border 0 - outline none - padding 10px - position absolute - bottom 0 - left 0 - text-align center - transition opacity 0.3s - width $sidebar-width - 16px - z-index 30 - - .sidebar-toggle-button:hover - opacity 0.4 - - span - background-color var(--theme-color, $color-primary) - display block - margin-bottom 4px - width 16px - height 2px - -body.sticky - .sidebar, .sidebar-toggle - position fixed - -/* main content */ -.content - padding-top 60px - position absolute - top 0 - right 0 - bottom 0 - left $sidebar-width - transition left 250ms ease - -/* markdown content found on pages */ -.markdown-section - margin 0 auto - max-width 800px - padding 30px 15px 40px 15px - position relative - - > * - box-sizing border-box - font-size inherit - - > :first-child - margin-top 0 !important - -.markdown-section hr - border none - border-bottom 1px solid #eee - margin 2em 0 - -.markdown-section iframe - border 1px solid #eee - /* fix horizontal overflow on iOS Safari */ - width 1px - min-width 100% - -.markdown-section table - border-collapse collapse - border-spacing 0 - display block - margin-bottom 1rem - overflow auto - width 100% - -.markdown-section th - border 1px solid #ddd - font-weight bold - padding 6px 13px - -.markdown-section td - border 1px solid #ddd - padding 6px 13px - -.markdown-section tr - border-top 1px solid #ccc - - &:nth-child(2n) - background-color #f8f8f8 - -.markdown-section p.tip - background-color #f8f8f8 - border-bottom-right-radius 2px - border-left 4px solid #f66 - border-top-right-radius 2px - margin 2em 0 - padding 12px 24px 12px 30px - position relative - - &:before - background-color #f66 - border-radius 100% - color $color-bg - content '!' - font-family 'Dosis', 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif - font-size 14px - font-weight bold - left -12px - line-height 20px - position absolute - height 20px - width 20px - text-align center - top 14px - - code - background-color #efefef - - em - color $color-text - -.markdown-section p.warn - background rgba($color-primary, 0.1) - border-radius 2px - padding 1rem - -.markdown-section ul.task-list > li - list-style-type none - -body.close - .sidebar - transform translateX(- $sidebar-width) - - .sidebar-toggle - width auto - - .content - left 0 - -@media print - .github-corner, .sidebar-toggle, .sidebar, .app-nav - display none - -@media screen and (max-width: 768px) - .github-corner, .sidebar-toggle, .sidebar - position fixed - - .app-nav - margin-top 16px - - .app-nav li ul - top 30px - - main - height auto - overflow-x hidden - - .sidebar - left - $sidebar-width - transition transform 250ms ease-out - - .content - left 0 - max-width 100vw - position static - padding-top 20px - transition transform 250ms ease - - .app-nav, .github-corner - transition transform 250ms ease-out - - .sidebar-toggle - background-color transparent - width auto - padding 30px 30px 10px 10px - - body.close - .sidebar - transform translateX($sidebar-width) - - .sidebar-toggle - background-color rgba($color-bg, 0.8) - transition 1s background-color - width $sidebar-width - 16px - padding 10px - - .content - transform translateX($sidebar-width) - - .app-nav, .github-corner - display none - - .github-corner - &:hover .octo-arm - animation none - - .octo-arm - animation octocat-wave 560ms ease-in-out - -@keyframes octocat-wave - 0%, 100% - transform rotate(0) - - 20%, 60% - transform rotate(-25deg) - - 40%, 80% - transform rotate(10deg) diff --git a/src/themes/buble.css b/src/themes/buble.css new file mode 100644 index 0000000..f70e6c0 --- /dev/null +++ b/src/themes/buble.css @@ -0,0 +1,239 @@ +@import url('https://fonts.googleapis.com/css?family=Inconsolata|Inconsolata-Bold'); + +$color-primary: #0074D9; +$color-bg: #fff; +$color-text: #34495e; +$sidebar-width: 16em; + +@import "basic/layout"; +@import "basic/coverpage"; + +/* sidebar */ +.sidebar { + color: #364149; + background-color: $color-bg; + + a { + color: #666; + text-decoration: none; + } + + li { + list-style: none; + margin: 0; + padding: 0.2em 0 0.2em 1em; + } + + ul li ul { + padding: 0; + } + + li.active { + a { + color: #333; + } + + background-color: #eee; + } +} + +.markdown-section h1, +.markdown-section h2, +.markdown-section h3, +.markdown-section h4, +.markdown-section strong { + color: #333; + font-weight: 400; +} + +.markdown-section a { + color: var(--theme-color, $color-primary); + font-weight: 400; +} + +.markdown-section p, +.markdown-section ul, +.markdown-section ol { + line-height: 1.6em; + margin: 0 0 1em 0; + word-spacing: 0.05em; +} + +.markdown-section h1 { + font-size: 2em; + font-weight: 500; + margin: 0 0 1em; +} + +.markdown-section h2 { + font-size: 1.8em; + font-weight: 400; + margin: 0 0 1rem 0; + padding: 1rem 0 0 0; +} + +.markdown-section h3 { + font-size: 1.5em; + margin: 52px 0 1.2em; +} + +.markdown-section h4 { + font-size: 1.25em; +} + +.markdown-section h5 { + font-size: 1em; +} + +.markdown-section h6 { + color: #777; + font-size: 1em; +} + +.markdown-section figure, +.markdown-section p, +.markdown-section ul, +.markdown-section ol { + margin: 1.2em 0; +} + +.markdown-section ul, +.markdown-section ol { + padding-left: 1.5em; +} + +.markdown-section li { + line-height: 1.5; + margin: 0; +} + +.markdown-section blockquote { + border-left: 4px solid var(--theme-color, $color-primary); + color: #858585; + margin: 2em 0; + padding-left: 20px; +} + +.markdown-section blockquote p { + font-weight: 600; + margin-left: 0; +} + +.markdown-section iframe { + margin: 1em 0; +} + +.markdown-section em { + color: #7f8c8d; +} + +.markdown-section code { + background-color: #f9f9f9; + border-radius: 3px; + font-family: Inconsolata; + padding: 0.2em 0.4em; + white-space: pre; +} + +.markdown-section pre { + background-color: #f9f9f9; + border-left: 2px solid #eee; + font-family: Inconsolata; + font-size: 16px; + margin: 0 0 1em 0; + padding: 8px; + padding: 0 10px 12px 0; + overflow: auto; + word-wrap: normal; +} + +/* code highlight */ +.token.cdata, +.token.comment, +.token.doctype, +.token.prolog { + color: #93a1a1; /* base1 */ +} + +.token.punctuation { + color: #586e75; /* base01 */ +} + +.namespace { + opacity: .7; +} + +.token.property, +.token.tag, +.token.boolean, +.token.number, +.token.constant, +.token.symbol, +.token.deleted { + color: #268bd2; /* blue */ +} + +.token.selector, +.token.attr-name, +.token.string, +.token.char, +.token.builtin, +.token.url, +.token.inserted { + color: #2aa198; /* cyan */ +} + +.token.entity { + color: #657b83; /* base00 */ + background: #eee8d5; /* base2 */ +} + +.token.atrule, +.token.attr-value, +.token.keyword { + color: #a11; /* green */ +} + +.token.function { + color: #b58900; /* yellow */ +} + +.token.regex, +.token.important, +.token.variable { + color: #cb4b16; /* orange */ +} + +.token.important, +.token.bold { + font-weight: bold; +} +.token.italic { + font-style: italic; +} + +.token.entity { + cursor: help; +} + +.markdown-section pre>code { + background-color: #f8f8f8; + border-radius: 2px; + display: block; + font-family: Inconsolata; + line-height: 1.1em; + max-width: inherit; + overflow: inherit; + padding: 20px 0.8em 20px; + position: relative; +} + +.markdown-section code::after, .markdown-section code::before { + letter-spacing: 0.05em; +} + +code .token { + -webkit-font-smoothing: initial; + -moz-osx-font-smoothing: initial; + min-height: 1.5em; +} diff --git a/src/themes/buble.styl b/src/themes/buble.styl deleted file mode 100644 index 53fbc15..0000000 --- a/src/themes/buble.styl +++ /dev/null @@ -1,173 +0,0 @@ -@import url('https://fonts.googleapis.com/css?family=Inconsolata|Inconsolata-Bold') - -$color-primary = #0074d9 -$color-bg = #fff -$color-text = #34495e -$sidebar-width = 16rem - -@import 'basic/_layout' -@import 'basic/_coverpage' - -/* sidebar */ -.sidebar - color #364149 - background-color $color-bg - - a - color #666 - text-decoration none - - li - list-style none - margin 0 - padding 0.2em 0 0.2em 0 - - ul li ul - padding 0 - - li.active - a - color #333 - - background-color #eee - -.markdown-section h1, .markdown-section h2, .markdown-section h3, .markdown-section h4, .markdown-section strong - color #333 - font-weight 400 - -.markdown-section a - color var(--theme-color, $color-primary) - font-weight 400 - -.markdown-section p, .markdown-section ul, .markdown-section ol - line-height 1.6rem - margin 0 0 1em 0 - word-spacing 0.05rem - -.markdown-section h1 - font-size 2rem - font-weight 500 - margin 0 0 1rem - -.markdown-section h2 - font-size 1.8rem - font-weight 400 - margin 0 0 1rem 0 - padding 1rem 0 0 0 - -.markdown-section h3 - font-size 1.5rem - margin 52px 0 1.2rem - -.markdown-section h4 - font-size 1.25rem - -.markdown-section h5 - font-size 1rem - -.markdown-section h6 - color #777 - font-size 1rem - -.markdown-section figure, .markdown-section p, .markdown-section ul, .markdown-section ol - margin 1.2em 0 - -.markdown-section ul, .markdown-section ol - padding-left 1.5rem - -.markdown-section li - line-height 1.5 - margin 0 - -.markdown-section blockquote - border-left 4px solid var(--theme-color, $color-primary) - color #858585 - margin 2em 0 - padding-left 20px - -.markdown-section blockquote p - font-weight 600 - margin-left 0 - -.markdown-section iframe - margin 1em 0 - -.markdown-section em - color #7f8c8d - -.markdown-section code - background-color #f9f9f9 - border-radius 3px - font-family Inconsolata - padding 0.2em 0.4rem - white-space nowrap - -.markdown-section pre - background-color #f9f9f9 - border-left 2px solid #eee - font-family Inconsolata - font-size 16px - margin 0 0 1em 0 - padding 8px - padding 0 10px 12px 0 - overflow auto - word-wrap normal - position relative - -/* code highlight */ -.token.cdata, .token.comment, .token.doctype, .token.prolog - color #93a1a1 /* base1 */ - -.token.punctuation - color #586e75 /* base01 */ - -.namespace - opacity 0.7 - -.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol, .token.deleted - color #268bd2 /* blue */ - -.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.url, .token.inserted - color #2aa198 /* cyan */ - -.token.entity - color #657b83 /* base00 */ - background #eee8d5 /* base2 */ - -.token.atrule, .token.attr-value, .token.keyword - color #a11 /* green */ - -.token.function - color #b58900 /* yellow */ - -.token.regex, .token.important, .token.variable - color #cb4b16 /* orange */ - -.token.important, .token.bold - font-weight bold - -.token.italic - font-style italic - -.token.entity - cursor help - -.markdown-section pre > code - background-color #f8f8f8 - border-radius 2px - display block - font-family Inconsolata - line-height 1.1rem - max-width inherit - overflow inherit - padding 20px 0.8em 20px - position relative - white-space inherit - -.markdown-section code::after, .markdown-section code::before - letter-spacing 0.05rem - -code .token - -webkit-font-smoothing initial - -moz-osx-font-smoothing initial - min-height 1.5rem diff --git a/src/themes/dark.css b/src/themes/dark.css new file mode 100644 index 0000000..5ee2585 --- /dev/null +++ b/src/themes/dark.css @@ -0,0 +1,299 @@ +@import url('https://fonts.googleapis.com/css?family=Roboto+Mono|Source+Sans+Pro:300,400,600'); + +$color-primary: #ea6f5a; +$color-bg: #3f3f3f; +$color-text: #c8c8c8; +$sidebar-width: 300px; + +@import "basic/layout"; +@import "basic/coverpage"; + +body { + background-color: $color-bg; +} + +/* sidebar */ +.sidebar { + background-color: $color-bg; + color: #c8c8c8; + + li { + margin: 6px 15px; + } + + ul li a { + color: #c8c8c8; + font-size: 14px; + overflow: hidden; + text-decoration: none; + text-overflow: ellipsis; + white-space: nowrap; + + &:hover { + text-decoration: underline; + } + } + + ul li ul { + padding: 0; + } + + ul li.active>a { + color: var(--theme-color, $color-primary); + font-weight: 600; + } +} + +/* markdown content found on pages */ +.markdown-section h1, +.markdown-section h2, +.markdown-section h3, +.markdown-section h4, +.markdown-section strong { + color: #2c3e50; + font-weight: 600; +} + +.markdown-section a { + color: var(--theme-color, $color-primary); + font-weight: 600; +} + +.markdown-section h1 { + font-size: 2em; + margin: 0 0 1em; +} + +.markdown-section h2 { + font-size: 1.75em; + margin: 45px 0 0.8em; +} + +.markdown-section h3 { + font-size: 1.5em; + margin: 40px 0 .6em; +} + +.markdown-section h4 { + font-size: 1.25em; +} + +.markdown-section h5 { + font-size: 1em; +} + +.markdown-section h6 { + color: #777; + font-size: 1em; +} + +.markdown-section figure, +.markdown-section p, +.markdown-section ul, +.markdown-section ol { + margin: 1.2em 0; +} + +.markdown-section p, +.markdown-section ul, +.markdown-section ol { + line-height: 1.6em; + word-spacing: 0.05em; +} + +.markdown-section ul, +.markdown-section ol { + padding-left: 1.5em; +} + +.markdown-section blockquote { + border-left: 4px solid var(--theme-color, $color-primary); + color: #858585; + margin: 2em 0; + padding-left: 20px; +} + +.markdown-section blockquote p { + font-weight: 600; + margin-left: 0; +} + +.markdown-section iframe { + margin: 1em 0; +} + +.markdown-section em { + color: #7f8c8d; +} + +.markdown-section code { + background-color: #282828; + border-radius: 2px; + color: #657b83; + font-family: 'Roboto Mono', Monaco, courier, monospace; + font-size: 0.8em; + margin: 0 2px; + padding: 3px 5px; + white-space: nowrap; +} + +.markdown-section pre { + -moz-osx-font-smoothing: initial; + -webkit-font-smoothing: initial; + background-color: #282828; + font-family: 'Roboto Mono', Monaco, courier, monospace; + line-height: 1.5em; + margin: 1.2em 0; + overflow: auto; + padding: 0 1.4em; + position: relative; + word-wrap: normal; +} + +/* code highlight */ +.token.comment, +.token.prolog, +.token.doctype, +.token.cdata { + color: #8e908c; +} + +.token.namespace { + opacity: .7; +} + +.token.boolean, +.token.number { + color: #c76b29; +} + +.token.punctuation { + color: #525252; +} + +.token.property { + color: #c08b30; +} + +.token.tag { + color: #2973b7; +} + +.token.string { + color: var(--theme-color, $color-primary); +} + +.token.selector { + color: #6679cc; +} + +.token.attr-name { + color: #2973b7; +} + +.token.entity, +.token.url, +.language-css .token.string, +.style .token.string { + color: #22a2c9; +} + +.token.attr-value, +.token.control, +.token.directive, +.token.unit { + color: var(--theme-color, $color-primary); +} + +.token.keyword { + color: #e96900; +} + +.token.statement, +.token.regex, +.token.atrule { + color: #22a2c9; +} + +.token.placeholder, +.token.variable { + color: #3d8fd1; +} + +.token.deleted { + text-decoration: line-through; +} + +.token.inserted { + border-bottom: 1px dotted #202746; + text-decoration: none; +} + +.token.italic { + font-style: italic; +} + +.token.important, +.token.bold { + font-weight: bold; +} + +.token.important { + color: #c94922; +} + +.token.entity { + cursor: help; +} + +.markdown-section pre>code { + -moz-osx-font-smoothing: initial; + -webkit-font-smoothing: initial; + background-color: #282828; + border-radius: 2px; + color: #657b83; + display: block; + font-family: 'Roboto Mono', Monaco, courier, monospace; + font-size: 0.8em; + line-height: inherit; + margin: 0 2px; + max-width: inherit; + overflow: inherit; + padding: 2.2em 5px; + white-space: inherit; +} + +.markdown-section code::after, .markdown-section code::before { + letter-spacing: 0.05em; +} + +code .token { + -moz-osx-font-smoothing: initial; + -webkit-font-smoothing: initial; + min-height: 1.5em; +} + +pre::after { + color: #ccc; + content: attr(data-lang); + font-size: 0.6em; + font-weight: 600; + height: 15px; + line-height: 15px; + padding: 5px 10px 0; + position: absolute; + right: 0; + text-align: right; + top: 0; +} + +.markdown-section p.tip { + background-color: #282828; + color: #657b83; +} + +input[type="search"] { + background: #4f4f4f; + border-color: #4f4f4f; + color: #c8c8c8; +} diff --git a/src/themes/dark.styl b/src/themes/dark.styl deleted file mode 100644 index 02ca630..0000000 --- a/src/themes/dark.styl +++ /dev/null @@ -1,225 +0,0 @@ -@import url('https://fonts.googleapis.com/css?family=Roboto+Mono|Source+Sans+Pro:300,400,600') - -$color-primary = #ea6f5a -$color-bg = #3f3f3f -$color-text = #c8c8c8 -$sidebar-width = 300px - -@import 'basic/_layout' -@import 'basic/_coverpage' - -body - background-color $color-bg - -/* sidebar */ -.sidebar - background-color $color-bg - color #c8c8c8 - - li - margin 6px 15px 6px 0 - - ul li a - color #c8c8c8 - font-size 14px - overflow hidden - text-decoration none - text-overflow ellipsis - white-space nowrap - - &:hover - text-decoration underline - - ul li ul - padding 0 - - ul li.active > a - color var(--theme-color, $color-primary) - font-weight 600 - -/* markdown content found on pages */ -.markdown-section h1, .markdown-section h2, .markdown-section h3, .markdown-section h4, .markdown-section strong - color #657b83 - font-weight 600 - -.markdown-section a - color var(--theme-color, $color-primary) - font-weight 600 - -.markdown-section h1 - font-size 2rem - margin 0 0 1rem - -.markdown-section h2 - font-size 1.75rem - margin 45px 0 0.8rem - -.markdown-section h3 - font-size 1.5rem - margin 40px 0 0.6rem - -.markdown-section h4 - font-size 1.25rem - -.markdown-section h5 - font-size 1rem - -.markdown-section h6 - color #777 - font-size 1rem - -.markdown-section figure, .markdown-section p, .markdown-section ul, .markdown-section ol - margin 1.2em 0 - -.markdown-section p, .markdown-section ul, .markdown-section ol - line-height 1.6rem - word-spacing 0.05rem - -.markdown-section ul, .markdown-section ol - padding-left 1.5rem - -.markdown-section blockquote - border-left 4px solid var(--theme-color, $color-primary) - color #858585 - margin 2em 0 - padding-left 20px - -.markdown-section blockquote p - font-weight 600 - margin-left 0 - -.markdown-section iframe - margin 1em 0 - -.markdown-section em - color #7f8c8d - -.markdown-section code - background-color #282828 - border-radius 2px - color #657b83 - font-family 'Roboto Mono', Monaco, courier, monospace - font-size 0.8rem - margin 0 2px - padding 3px 5px - white-space pre-wrap - -.markdown-section pre - -moz-osx-font-smoothing initial - -webkit-font-smoothing initial - background-color #282828 - font-family 'Roboto Mono', Monaco, courier, monospace - line-height 1.5rem - margin 1.2em 0 - overflow auto - padding 0 1.4rem - position relative - word-wrap normal - -/* code highlight */ -.token.comment, .token.prolog, .token.doctype, .token.cdata - color #8e908c - -.token.namespace - opacity 0.7 - -.token.boolean, .token.number - color #c76b29 - -.token.punctuation - color #525252 - -.token.property - color #c08b30 - -.token.tag - color #2973b7 - -.token.string - color var(--theme-color, $color-primary) - -.token.selector - color #6679cc - -.token.attr-name - color #2973b7 - -.token.entity, .token.url, .language-css .token.string, .style .token.string - color #22a2c9 - -.token.attr-value, .token.control, .token.directive, .token.unit - color var(--theme-color, $color-primary) - -.token.keyword - color #e96900 - -.token.statement, .token.regex, .token.atrule - color #22a2c9 - -.token.placeholder, .token.variable - color #3d8fd1 - -.token.deleted - text-decoration line-through - -.token.inserted - border-bottom 1px dotted #202746 - text-decoration none - -.token.italic - font-style italic - -.token.important, .token.bold - font-weight bold - -.token.important - color #c94922 - -.token.entity - cursor help - -.markdown-section pre > code - -moz-osx-font-smoothing initial - -webkit-font-smoothing initial - background-color #282828 - border-radius 2px - color #657b83 - display block - font-family 'Roboto Mono', Monaco, courier, monospace - font-size 0.8rem - line-height inherit - margin 0 2px - max-width inherit - overflow inherit - padding 2.2em 5px - white-space inherit - -.markdown-section code::after, .markdown-section code::before - letter-spacing 0.05rem - -code .token - -moz-osx-font-smoothing initial - -webkit-font-smoothing initial - min-height 1.5rem - -pre::after - color #ccc - content attr(data-lang) - font-size 0.6rem - font-weight 600 - height 15px - line-height 15px - padding 5px 10px 0 - position absolute - right 0 - text-align right - top 0 - -.markdown-section p.tip - background-color #282828 - color #657b83 - -input[type='search'] - background #4f4f4f - border-color #4f4f4f - color #c8c8c8 diff --git a/src/themes/dolphin.styl b/src/themes/dolphin.styl deleted file mode 100644 index f5ea286..0000000 --- a/src/themes/dolphin.styl +++ /dev/null @@ -1,228 +0,0 @@ -@import url('https://fonts.googleapis.com/css?family=Thasadith:400,400i,700') - -$color-primary = #00ffff -$color-bg = #f0ffff -$color-text = #34495e -$sidebar-width = 300px - -@import 'basic/_layout' -@import 'basic/_coverpage' - -body - background-color $color-bg - -/* sidebar */ -.sidebar - background-color $color-bg - color #364149 - - li - margin 6px 0 6px 0 - - ul li a - color #505d6b - font-size 14px - font-weight normal - overflow hidden - text-decoration none - text-overflow ellipsis - white-space nowrap - - &:hover - text-decoration underline - - ul li ul - padding 0 - - ul li.active > a - border-right 2px solid - color var(--theme-color, $color-primary) - font-weight 600 - -.app-sub-sidebar - li - &::before - content '-' - padding-right 4px - float left - -/* markdown content found on pages */ -.markdown-section h1, .markdown-section h2, .markdown-section h3, .markdown-section h4, .markdown-section strong - color #2c3e50 - font-weight 600 - -.markdown-section a - color var(--theme-color, $color-primary) - font-weight 600 - - &:hover - text-decoration underline - -.markdown-section h1 - font-size 2rem - margin 0 0 1rem - -.markdown-section h2 - font-size 1.75rem - margin 45px 0 0.8rem - -.markdown-section h3 - font-size 1.5rem - margin 40px 0 0.6rem - -.markdown-section h4 - font-size 1.25rem - -.markdown-section h5 - font-size 1rem - -.markdown-section h6 - color #777 - font-size 1rem - -.markdown-section figure, .markdown-section p - margin 1.2em 0 - -.markdown-section p, .markdown-section ul, .markdown-section ol - line-height 1.6rem - word-spacing 0.05rem - -.markdown-section ul, .markdown-section ol - padding-left 1.5rem - -.markdown-section blockquote - border-left 4px solid var(--theme-color, $color-primary) - color #858585 - margin 2em 0 - padding-left 20px - -.markdown-section blockquote p - font-weight 600 - margin-left 0 - -.markdown-section iframe - margin 1em 0 - -.markdown-section em - color #7f8c8d - -.markdown-section code - background-color #f8f8f8 - border-radius 2px - color #e96900 - font-family 'Roboto Mono', Monaco, courier, monospace - font-size 0.8rem - margin 0 2px - padding 3px 5px - white-space pre-wrap - -.markdown-section pre - -moz-osx-font-smoothing initial - -webkit-font-smoothing initial - background-color #f8f8f8 - font-family 'Roboto Mono', Monaco, courier, monospace - line-height 1.5rem - margin 1.2em 0 - overflow auto - padding 0 1.4rem - position relative - word-wrap normal - -/* code highlight */ -.token.comment, .token.prolog, .token.doctype, .token.cdata - color #8e908c - -.token.namespace - opacity 0.7 - -.token.boolean, .token.number - color #c76b29 - -.token.punctuation - color #525252 - -.token.property - color #c08b30 - -.token.tag - color #2973b7 - -.token.string - color var(--theme-color, $color-primary) - -.token.selector - color #6679cc - -.token.attr-name - color #2973b7 - -.token.entity, .token.url, .language-css .token.string, .style .token.string - color #22a2c9 - -.token.attr-value, .token.control, .token.directive, .token.unit - color var(--theme-color, $color-primary) - -.token.keyword, .token.function - color #e96900 - -.token.statement, .token.regex, .token.atrule - color #22a2c9 - -.token.placeholder, .token.variable - color #3d8fd1 - -.token.deleted - text-decoration line-through - -.token.inserted - border-bottom 1px dotted #202746 - text-decoration none - -.token.italic - font-style italic - -.token.important, .token.bold - font-weight bold - -.token.important - color #c94922 - -.token.entity - cursor help - -.markdown-section pre > code - -moz-osx-font-smoothing initial - -webkit-font-smoothing initial - background-color #f8f8f8 - border-radius 2px - color #525252 - display block - font-family 'Roboto Mono', Monaco, courier, monospace - font-size 0.8rem - line-height inherit - margin 0 2px - max-width inherit - overflow inherit - padding 2.2em 5px - white-space inherit - -.markdown-section code::after, .markdown-section code::before - letter-spacing 0.05rem - -code .token - -moz-osx-font-smoothing initial - -webkit-font-smoothing initial - min-height 1.5rem - -pre::after - color #ccc - content attr(data-lang) - font-size 0.6rem - font-weight 600 - height 15px - line-height 15px - padding 5px 10px 0 - position absolute - right 0 - text-align right - top 0 diff --git a/src/themes/pure.css b/src/themes/pure.css new file mode 100644 index 0000000..070c070 --- /dev/null +++ b/src/themes/pure.css @@ -0,0 +1,5 @@ +$color-primary: #000; +$color-bg: #fff; +$color-text: #000; +$sidebar-width: 300px; +@import "basic/layout"; diff --git a/src/themes/pure.styl b/src/themes/pure.styl deleted file mode 100644 index 37d0b76..0000000 --- a/src/themes/pure.styl +++ /dev/null @@ -1,7 +0,0 @@ -$color-primary = #000 -$color-bg = #fff -$color-text = #000 -$sidebar-width = 300px - -@import 'basic/_layout' -@import 'basic/_coverpage' diff --git a/src/themes/vue.css b/src/themes/vue.css new file mode 100644 index 0000000..818123d --- /dev/null +++ b/src/themes/vue.css @@ -0,0 +1,299 @@ +@import url('https://fonts.googleapis.com/css?family=Roboto+Mono|Source+Sans+Pro:300,400,600'); + +$color-primary: #42b983; +$color-bg: #fff; +$color-text: #34495e; +$sidebar-width: 300px; + +@import "basic/layout"; +@import "basic/coverpage"; + +body { + background-color: $color-bg; +} + +/* sidebar */ +.sidebar { + background-color: $color-bg; + color: #364149; + + li { + margin: 6px 0 6px 15px; + } + + ul li a { + color: #505d6b; + font-size: 14px; + font-weight: normal; + overflow: hidden; + text-decoration: none; + text-overflow: ellipsis; + white-space: nowrap; + + &:hover { + text-decoration: underline; + } + } + + ul li ul { + padding: 0; + } + + ul li.active>a { + border-right: 2px solid; + color: var(--theme-color, $color-primary); + font-weight: 600; + } +} + +.app-sub-sidebar { + .section-link { + &::before { + content: '-'; + padding-right: 4px; + } + } +} + +/* markdown content found on pages */ +.markdown-section h1, +.markdown-section h2, +.markdown-section h3, +.markdown-section h4, +.markdown-section strong { + color: #2c3e50; + font-weight: 600; +} + +.markdown-section a { + color: var(--theme-color, $color-primary); + font-weight: 600; +} + +.markdown-section h1 { + font-size: 2em; + margin: 0 0 1em; +} + +.markdown-section h2 { + font-size: 1.75em; + margin: 45px 0 0.8em; +} + +.markdown-section h3 { + font-size: 1.5em; + margin: 40px 0 .6em; +} + +.markdown-section h4 { + font-size: 1.25em; +} + +.markdown-section h5 { + font-size: 1em; +} + +.markdown-section h6 { + color: #777; + font-size: 1em; +} + +.markdown-section figure, +.markdown-section p, +.markdown-section ul, +.markdown-section ol { + margin: 1.2em 0; +} + +.markdown-section p, +.markdown-section ul, +.markdown-section ol { + line-height: 1.6em; + word-spacing: 0.05em; +} + +.markdown-section ul, +.markdown-section ol { + padding-left: 1.5em; +} + +.markdown-section blockquote { + border-left: 4px solid var(--theme-color, $color-primary); + color: #858585; + margin: 2em 0; + padding-left: 20px; +} + +.markdown-section blockquote p { + font-weight: 600; + margin-left: 0; +} + +.markdown-section iframe { + margin: 1em 0; +} + +.markdown-section em { + color: #7f8c8d; +} + +.markdown-section code { + background-color: #f8f8f8; + border-radius: 2px; + color: #e96900; + font-family: 'Roboto Mono', Monaco, courier, monospace; + font-size: 0.8em; + margin: 0 2px; + padding: 3px 5px; + white-space: nowrap; +} + +.markdown-section pre { + -moz-osx-font-smoothing: initial; + -webkit-font-smoothing: initial; + background-color: #f8f8f8; + font-family: 'Roboto Mono', Monaco, courier, monospace; + line-height: 1.5em; + margin: 1.2em 0; + overflow: auto; + padding: 0 1.4em; + position: relative; + word-wrap: normal; +} + +/* code highlight */ +.token.comment, +.token.prolog, +.token.doctype, +.token.cdata { + color: #8e908c; +} + +.token.namespace { + opacity: .7; +} + +.token.boolean, +.token.number { + color: #c76b29; +} + +.token.punctuation { + color: #525252; +} + +.token.property { + color: #c08b30; +} + +.token.tag { + color: #2973b7; +} + +.token.string { + color: var(--theme-color, $color-primary); +} + +.token.selector { + color: #6679cc; +} + +.token.attr-name { + color: #2973b7; +} + +.token.entity, +.token.url, +.language-css .token.string, +.style .token.string { + color: #22a2c9; +} + +.token.attr-value, +.token.control, +.token.directive, +.token.unit { + color: var(--theme-color, $color-primary); +} + +.token.keyword { + color: #e96900; +} + +.token.statement, +.token.regex, +.token.atrule { + color: #22a2c9; +} + +.token.placeholder, +.token.variable { + color: #3d8fd1; +} + +.token.deleted { + text-decoration: line-through; +} + +.token.inserted { + border-bottom: 1px dotted #202746; + text-decoration: none; +} + +.token.italic { + font-style: italic; +} + +.token.important, +.token.bold { + font-weight: bold; +} + +.token.important { + color: #c94922; +} + +.token.entity { + cursor: help; +} + +.markdown-section pre>code { + -moz-osx-font-smoothing: initial; + -webkit-font-smoothing: initial; + background-color: #f8f8f8; + border-radius: 2px; + color: #525252; + display: block; + font-family: 'Roboto Mono', Monaco, courier, monospace; + font-size: 0.8em; + line-height: inherit; + margin: 0 2px; + max-width: inherit; + overflow: inherit; + padding: 2.2em 5px; + white-space: inherit; +} + +.markdown-section code::after, .markdown-section code::before { + letter-spacing: 0.05em; +} + +code .token { + -moz-osx-font-smoothing: initial; + -webkit-font-smoothing: initial; + min-height: 1.5em; +} + +pre::after { + color: #ccc; + content: attr(data-lang); + font-size: 0.6em; + font-weight: 600; + height: 15px; + line-height: 15px; + padding: 5px 10px 0; + position: absolute; + right: 0; + text-align: right; + top: 0; +} diff --git a/src/themes/vue.styl b/src/themes/vue.styl deleted file mode 100644 index 98c416e..0000000 --- a/src/themes/vue.styl +++ /dev/null @@ -1,225 +0,0 @@ -@import url('https://fonts.googleapis.com/css?family=Roboto+Mono|Source+Sans+Pro:300,400,600') - -$color-primary = #42b983 -$color-bg = #fff -$color-text = #34495e -$sidebar-width = 300px - -@import 'basic/_layout' -@import 'basic/_coverpage' - -body - background-color $color-bg - -/* sidebar */ -.sidebar - background-color $color-bg - color #364149 - - li - margin 6px 0 6px 0 - - ul li a - color #505d6b - font-size 14px - font-weight normal - overflow hidden - text-decoration none - text-overflow ellipsis - white-space nowrap - - &:hover - text-decoration underline - - ul li ul - padding 0 - - ul li.active > a - border-right 2px solid - color var(--theme-color, $color-primary) - font-weight 600 - -.app-sub-sidebar - li - &::before - content '-' - padding-right 4px - float left - -/* markdown content found on pages */ -.markdown-section h1, .markdown-section h2, .markdown-section h3, .markdown-section h4, .markdown-section strong - color #2c3e50 - font-weight 600 - -.markdown-section a - color var(--theme-color, $color-primary) - font-weight 600 - -.markdown-section h1 - font-size 2rem - margin 0 0 1rem - -.markdown-section h2 - font-size 1.75rem - margin 45px 0 0.8rem - -.markdown-section h3 - font-size 1.5rem - margin 40px 0 0.6rem - -.markdown-section h4 - font-size 1.25rem - -.markdown-section h5 - font-size 1rem - -.markdown-section h6 - color #777 - font-size 1rem - -.markdown-section figure, .markdown-section p - margin 1.2em 0 - -.markdown-section p, .markdown-section ul, .markdown-section ol - line-height 1.6rem - word-spacing 0.05rem - -.markdown-section ul, .markdown-section ol - padding-left 1.5rem - -.markdown-section blockquote - border-left 4px solid var(--theme-color, $color-primary) - color #858585 - margin 2em 0 - padding-left 20px - -.markdown-section blockquote p - font-weight 600 - margin-left 0 - -.markdown-section iframe - margin 1em 0 - -.markdown-section em - color #7f8c8d - -.markdown-section code - background-color #f8f8f8 - border-radius 2px - color #e96900 - font-family 'Roboto Mono', Monaco, courier, monospace - font-size 0.8rem - margin 0 2px - padding 3px 5px - white-space pre-wrap - -.markdown-section pre - -moz-osx-font-smoothing initial - -webkit-font-smoothing initial - background-color #f8f8f8 - font-family 'Roboto Mono', Monaco, courier, monospace - line-height 1.5rem - margin 1.2em 0 - overflow auto - padding 0 1.4rem - position relative - word-wrap normal - -/* code highlight */ -.token.comment, .token.prolog, .token.doctype, .token.cdata - color #8e908c - -.token.namespace - opacity 0.7 - -.token.boolean, .token.number - color #c76b29 - -.token.punctuation - color #525252 - -.token.property - color #c08b30 - -.token.tag - color #2973b7 - -.token.string - color var(--theme-color, $color-primary) - -.token.selector - color #6679cc - -.token.attr-name - color #2973b7 - -.token.entity, .token.url, .language-css .token.string, .style .token.string - color #22a2c9 - -.token.attr-value, .token.control, .token.directive, .token.unit - color var(--theme-color, $color-primary) - -.token.keyword, .token.function - color #e96900 - -.token.statement, .token.regex, .token.atrule - color #22a2c9 - -.token.placeholder, .token.variable - color #3d8fd1 - -.token.deleted - text-decoration line-through - -.token.inserted - border-bottom 1px dotted #202746 - text-decoration none - -.token.italic - font-style italic - -.token.important, .token.bold - font-weight bold - -.token.important - color #c94922 - -.token.entity - cursor help - -.markdown-section pre > code - -moz-osx-font-smoothing initial - -webkit-font-smoothing initial - background-color #f8f8f8 - border-radius 2px - color #525252 - display block - font-family 'Roboto Mono', Monaco, courier, monospace - font-size 0.8rem - line-height inherit - margin 0 2px - max-width inherit - overflow inherit - padding 2.2em 5px - white-space inherit - -.markdown-section code::after, .markdown-section code::before - letter-spacing 0.05rem - -code .token - -moz-osx-font-smoothing initial - -webkit-font-smoothing initial - min-height 1.5rem - -pre::after - color #ccc - content attr(data-lang) - font-size 0.6rem - font-weight 600 - height 15px - line-height 15px - padding 5px 10px 0 - position absolute - right 0 - text-align right - top 0 diff --git a/test/_helper.js b/test/_helper.js deleted file mode 100644 index 4b4abce..0000000 --- a/test/_helper.js +++ /dev/null @@ -1,87 +0,0 @@ -// load ES6 modules in Node.js on the fly -require = require('esm')(module/*, options*/) - -const path = require('path') -const {expect} = require('chai') - -const {JSDOM} = require('jsdom') - -function ready(callback) { - const state = document.readyState - - if (state === 'complete' || state === 'interactive') { - return setTimeout(callback, 0) - } - - document.addEventListener('DOMContentLoaded', callback) -} -module.exports.init = function(fixture = 'default', config = {}, markup) { - if (markup == null) { - markup = ` - - - - - - - ` - } - const rootPath = path.join(__dirname, 'fixtures', fixture) - - const dom = new JSDOM(markup) - dom.reconfigure({ url: 'file:///' + rootPath }) - - global.window = dom.window - global.document = dom.window.document - global.navigator = dom.window.navigator - global.location = dom.window.location - global.XMLHttpRequest = dom.window.XMLHttpRequest - - // mimic src/core/index.js but for Node.js - function Docsify() { - this._init() - } - - const proto = Docsify.prototype - - const {initMixin} = require('../src/core/init') - const {routerMixin} = require('../src/core//router') - const {renderMixin} = require('../src/core//render') - const {fetchMixin} = require('../src/core/fetch') - const {eventMixin} = require('../src/core//event') - - initMixin(proto) - routerMixin(proto) - renderMixin(proto) - fetchMixin(proto) - eventMixin(proto) - - const NOT_INIT_PATTERN = '' - - return new Promise((resolve, reject) => { - ready(() => { - const docsify = new Docsify() - // NOTE: I was not able to get it working with a callback, but polling works usually at the first time - const id = setInterval(() => { - if (dom.window.document.body.innerHTML.indexOf(NOT_INIT_PATTERN) == -1) { - clearInterval(id) - return resolve({ - docsify: docsify, - dom: dom - }) - } - }, 10) - }) - - }) -} -module.exports.expectSameDom = function(actual, expected) { - const WHITESPACES_BETWEEN_TAGS = />(\s\s+) diff --git a/test/fixtures/simple/README.md b/test/fixtures/simple/README.md deleted file mode 100644 index 0f3fd46..0000000 --- a/test/fixtures/simple/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# Heading - -[another page](other.md) - -## II 1 - -### III 1 - -#### IV 1 - -##### V 1 - - -## II 2 - -### III 2 - -#### IV 2 diff --git a/test/fixtures/simple/other-page.md b/test/fixtures/simple/other-page.md deleted file mode 100644 index 4bc6e98..0000000 --- a/test/fixtures/simple/other-page.md +++ /dev/null @@ -1,16 +0,0 @@ -# Other - -## two 1 - -### three 1 - -#### four 1 - -##### five 1 - - -## two 2 - -### three 2 - -#### four 2 diff --git a/test/integration/render.js b/test/integration/render.js deleted file mode 100644 index 7b2b253..0000000 --- a/test/integration/render.js +++ /dev/null @@ -1,14 +0,0 @@ -const path = require('path') - -const {expect} = require('chai') - -const {init, expectSameDom} = require('../_helper') - -describe('full docsify initialization', function() { - it('TODO: check generated markup', async function() { - const {docsify, dom} = await init('simple', {loadSidebar: true}) - console.log(dom.window.document.body.innerHTML) - // TODO: add some expectations - }) - -}) diff --git a/test/integration/router.js b/test/integration/router.js deleted file mode 100644 index b87e802..0000000 --- a/test/integration/router.js +++ /dev/null @@ -1,14 +0,0 @@ -const path = require('path') - -const {expect} = require('chai') - -const {init, expectSameDom} = require('../_helper') - -describe('router', function() { - it('TODO: trigger to load another page', async function() { - const {docsify} = await init() - window.location = '/?foo=bar' - // TODO: add some expectations - }) - -}) diff --git a/test/unit/base.js b/test/unit/base.js deleted file mode 100644 index 036700b..0000000 --- a/test/unit/base.js +++ /dev/null @@ -1,62 +0,0 @@ -/* eslint-env node, chai, mocha */ -require = require('esm')(module/*, options*/) -const {expect} = require('chai') -const {History} = require('../../src/core/router/history/base') - -class MockHistory extends History { - parse(path) { - return {path} - } -} - -describe('router/history/base', function () { - describe('relativePath true', function () { - var history - - beforeEach(function () { - history = new MockHistory({relativePath: true}) - }) - - it('toURL', function () { - // WHEN - const url = history.toURL('guide.md', {}, '/zh-ch/') - - // THEN - expect(url).equal('/zh-ch/guide') - }) - - it('toURL with double dot', function () { - // WHEN - const url = history.toURL('../README.md', {}, '/zh-ch/') - - // THEN - expect(url).equal('/README') - }) - - it('toURL child path', function () { - // WHEN - const url = history.toURL('config/example.md', {}, '/zh-ch/') - - // THEN - expect(url).equal('/zh-ch/config/example') - }) - - it('toURL absolute path', function () { - // WHEN - const url = history.toURL('/README', {}, '/zh-ch/') - - // THEN - expect(url).equal('/README') - }) - }) - - it('toURL without relative path', function () { - const history = new MockHistory({relativePath: false}) - - // WHEN - const url = history.toURL('README', {}, '/zh-ch/') - - // THEN - expect(url).equal('/README') - }) -}) diff --git a/test/unit/render.js b/test/unit/render.js deleted file mode 100644 index 25043cf..0000000 --- a/test/unit/render.js +++ /dev/null @@ -1,89 +0,0 @@ -const path = require('path') - -const {expect} = require('chai') - -const {init, expectSameDom} = require('../_helper') - -describe('render', function() { - it('important content (tips)', async function() { - const {docsify, dom} = await init() - const output = docsify.compiler.compile('!> **Time** is money, my friend!') - expect(output).equal('Time is money, my friend!
') - }) - - describe('lists', function() { - it('as unordered task list', async function() { - const {docsify, dom} = await init() - const output = docsify.compiler.compile(` -- [x] Task 1 -- [ ] Task 2 -- [ ] Task 3`) - expect(output, `-
-
-
-
-
-
-
-
-
-
-
-
-
text
--
-
-
-