@@ -30,7 +30,7 @@ export default class Renderer {
30
30
config,
31
31
cache
32
32
} ) {
33
- this . html = this . template = template
33
+ this . html = template
34
34
this . path = cwd ( path )
35
35
this . config = Object . assign ( config , {
36
36
routerMode : 'history'
@@ -43,10 +43,12 @@ export default class Renderer {
43
43
this . router . getCurrentPath = ( ) => this . url
44
44
this . _renderHtml ( 'inject-config' , `<script>window.$docsify = ${ JSON . stringify ( config ) } </script>` )
45
45
this . _renderHtml ( 'inject-app' , mainTpl ( config ) )
46
+
47
+ this . template = this . html
46
48
}
47
49
48
50
renderToString ( url ) {
49
- this . url = url
51
+ this . url = url = this . router . parse ( url ) . path
50
52
// TODO render cover page
51
53
const { loadSidebar, loadNavbar } = this . config
52
54
@@ -65,19 +67,26 @@ export default class Renderer {
65
67
this . _renderHtml ( 'navbar' , this . _render ( navbarFile , 'navbar' ) )
66
68
}
67
69
68
- return this . html
70
+ const html = this . html
71
+ this . html = this . template
72
+
73
+ return html
69
74
}
70
75
71
76
_renderHtml ( match , content ) {
72
- this . html = this . html . replace ( new RegExp ( `<!--${ match } -->` , 'g' ) , content )
77
+ return this . html = this . html . replace ( new RegExp ( `<!--${ match } -->` , 'g' ) , content )
73
78
}
74
79
75
80
_render ( path , type ) {
76
81
let html = this . _loadFile ( path )
82
+ const { subMaxLevel, maxLevel } = this . config
77
83
78
84
switch ( type ) {
79
85
case 'sidebar' :
80
- html = this . compiler . sidebar ( html )
86
+ html = this . compiler . sidebar ( html , maxLevel )
87
+ + `<script>window.__SUB_SIDEBAR__ = ${ JSON . stringify (
88
+ this . compiler . subSidebar ( html , subMaxLevel )
89
+ ) } </script>`
81
90
break
82
91
case 'cover' :
83
92
html = this . compiler . cover ( html )
0 commit comments