@@ -13,9 +13,9 @@ function cwd (...args) {
13
13
}
14
14
15
15
function mainTpl ( config ) {
16
- let html = `<nav class="app-nav${ config . repo
17
- ? ''
18
- : ' no-badge' } "><!--navbar--></nav>`
16
+ let html = `<nav class="app-nav${
17
+ config . repo ? '' : ' no-badge '
18
+ } "><!--navbar--></nav>`
19
19
20
20
if ( config . repo ) {
21
21
html += tpl . corner ( config . repo )
@@ -58,7 +58,7 @@ export default class Renderer {
58
58
59
59
async renderToString ( url ) {
60
60
this . url = url = this . router . parse ( url ) . path
61
- const { loadSidebar, loadNavbar } = this . config
61
+ const { loadSidebar, loadNavbar, coverpage } = this . config
62
62
63
63
const mainFile = this . _getPath ( url )
64
64
this . _renderHtml ( 'main' , await this . _render ( mainFile ) )
@@ -75,6 +75,24 @@ export default class Renderer {
75
75
this . _renderHtml ( 'navbar' , await this . _render ( navbarFile , 'navbar' ) )
76
76
}
77
77
78
+ if ( coverpage ) {
79
+ let path = null
80
+ if ( typeof coverpage === 'string' ) {
81
+ if ( url === '/' ) {
82
+ path = coverpage
83
+ }
84
+ } else if ( Array . isArray ( coverpage ) ) {
85
+ path = coverpage . indexOf ( url ) > - 1 && '_coverpage.md'
86
+ } else {
87
+ const cover = coverpage [ url ]
88
+ path = cover === true ? '_coverpage.md' : cover
89
+ }
90
+
91
+ const coverFile = this . _getPath ( resolve ( url , `./${ path } ` ) )
92
+
93
+ this . _renderHtml ( 'cover' , await this . _render ( coverFile ) , 'cover' )
94
+ }
95
+
78
96
const html = this . html
79
97
this . html = this . template
80
98
0 commit comments