Commit f68ddf5 1 parent 9755439 commit f68ddf5 Copy full SHA for f68ddf5
File tree 2 files changed +27
-11
lines changed
2 files changed +27
-11
lines changed Original file line number Diff line number Diff line change @@ -70,17 +70,31 @@ export function fetchMixin (proto) {
70
70
const { coverpage } = this . config
71
71
const query = this . route . query
72
72
const root = getParentPath ( this . route . path )
73
- const path = this . router . getFile ( root + coverpage )
74
73
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
+ }
79
87
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
+ }
84
98
}
85
99
86
100
proto . $fetch = function ( cb = noop ) {
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ export function cover () {
57
57
`hsl(${ Math . floor ( Math . random ( ) * 255 ) + SL } ) 100%)`
58
58
59
59
return (
60
- `<section class="cover" style="background: ${ bgc } ">` +
60
+ `<section class="cover show " style="background: ${ bgc } ">` +
61
61
'<div class="cover-main"></div>' +
62
62
'<div class="mask"></div>' +
63
63
'</section>'
@@ -74,7 +74,9 @@ export function tree (toc, tpl = '') {
74
74
if ( ! toc || ! toc . length ) return ''
75
75
76
76
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>`
78
80
if ( node . children ) {
79
81
tpl += `<li><ul class="children">${ tree ( node . children ) } </li></ul>`
80
82
}
You can’t perform that action at this time.
0 commit comments