File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,17 +70,31 @@ export function fetchMixin (proto) {
7070 const { coverpage } = this . config
7171 const query = this . route . query
7272 const root = getParentPath ( this . route . path )
73- const path = this . router . getFile ( root + coverpage )
7473
75- if ( this . route . path !== '/' || ! coverpage ) {
76- this . _renderCover ( )
77- return
78- }
74+ if ( coverpage ) {
75+ let path = null
76+ const routePath = this . route . path
77+ if ( typeof coverpage === 'string' ) {
78+ if ( routePath === '/' ) {
79+ path = coverpage
80+ }
81+ } else if ( Array . isArray ( coverpage ) ) {
82+ path = coverpage . indexOf ( routePath ) > - 1 && '_coverpage.md'
83+ } else {
84+ const cover = coverpage [ routePath ]
85+ path = cover === true ? '_coverpage.md' : cover
86+ }
7987
80- this . coverIsHTML = / \. h t m l $ / g. test ( path )
81- get ( path + stringifyQuery ( query , [ 'id' ] ) ) . then ( text =>
82- this . _renderCover ( text )
83- )
88+ if ( path ) {
89+ path = this . router . getFile ( root + path )
90+ this . coverIsHTML = / \. h t m l $ / g. test ( path )
91+ get ( path + stringifyQuery ( query , [ 'id' ] ) ) . then ( text =>
92+ this . _renderCover ( text )
93+ )
94+ } else {
95+ this . _renderCover ( )
96+ }
97+ }
8498 }
8599
86100 proto . $fetch = function ( cb = noop ) {
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ export function cover () {
5757 `hsl(${ Math . floor ( Math . random ( ) * 255 ) + SL } ) 100%)`
5858
5959 return (
60- `<section class="cover" style="background: ${ bgc } ">` +
60+ `<section class="cover show " style="background: ${ bgc } ">` +
6161 '<div class="cover-main"></div>' +
6262 '<div class="mask"></div>' +
6363 '</section>'
@@ -74,7 +74,9 @@ export function tree (toc, tpl = '') {
7474 if ( ! toc || ! toc . length ) return ''
7575
7676 toc . forEach ( node => {
77- tpl += `<li><a class="section-link" href="${ node . slug } ">${ node . title } </a></li>`
77+ tpl += `<li><a class="section-link" href="${ node . slug } ">${
78+ node . title
79+ } </a></li>`
7880 if ( node . children ) {
7981 tpl += `<li><ul class="children">${ tree ( node . children ) } </li></ul>`
8082 }
You can’t perform that action at this time.
0 commit comments