diff --git a/src/core/fetch/index.js b/src/core/fetch/index.js index 858395f00..3594f5a6d 100644 --- a/src/core/fetch/index.js +++ b/src/core/fetch/index.js @@ -70,17 +70,31 @@ export function fetchMixin (proto) { const { coverpage } = this.config const query = this.route.query const root = getParentPath(this.route.path) - const path = this.router.getFile(root + coverpage) - if (this.route.path !== '/' || !coverpage) { - this._renderCover() - return - } + if (coverpage) { + let path = null + const routePath = this.route.path + if (typeof coverpage === 'string') { + if (routePath === '/') { + path = coverpage + } + } else if (Array.isArray(coverpage)) { + path = coverpage.indexOf(routePath) > -1 && '_coverpage.md' + } else { + const cover = coverpage[routePath] + path = cover === true ? '_coverpage.md' : cover + } - this.coverIsHTML = /\.html$/g.test(path) - get(path + stringifyQuery(query, ['id'])).then(text => - this._renderCover(text) - ) + if (path) { + path = this.router.getFile(root + path) + this.coverIsHTML = /\.html$/g.test(path) + get(path + stringifyQuery(query, ['id'])).then(text => + this._renderCover(text) + ) + } else { + this._renderCover() + } + } } proto.$fetch = function (cb = noop) { diff --git a/src/core/render/tpl.js b/src/core/render/tpl.js index 76bf14f92..8db1caf0f 100644 --- a/src/core/render/tpl.js +++ b/src/core/render/tpl.js @@ -57,7 +57,7 @@ export function cover () { `hsl(${Math.floor(Math.random() * 255) + SL}) 100%)` return ( - `
` + + `
` + '
' + '
' + '
' @@ -74,7 +74,9 @@ export function tree (toc, tpl = '') { if (!toc || !toc.length) return '' toc.forEach(node => { - tpl += `
  • ${node.title}
  • ` + tpl += `
  • ${ + node.title + }
  • ` if (node.children) { tpl += `
  • ` }