@@ -11,7 +11,7 @@ function cwd (...args) {
1111}
1212
1313function mainTpl ( config ) {
14- let html = `<nav class="app-nav${ config . repo ? '' : 'no-badge' } "><!--navbar--></nav>`
14+ let html = `<nav class="app-nav${ config . repo ? '' : ' no-badge' } "><!--navbar--></nav>`
1515
1616 if ( config . repo ) {
1717 html += tpl . corner ( config . repo )
@@ -28,12 +28,10 @@ function mainTpl (config) {
2828export default class Renderer {
2929 constructor ( {
3030 template,
31- context,
3231 config,
3332 cache
3433 } ) {
3534 this . html = template
36- this . context = cwd ( context || './' )
3735 this . config = config = Object . assign ( { } , config , {
3836 routerMode : 'history'
3937 } )
@@ -54,7 +52,7 @@ export default class Renderer {
5452
5553 return isAbsolutePath ( file )
5654 ? file
57- : cwd ( this . context , `./${ file } ` )
55+ : cwd ( `./${ file } ` )
5856 }
5957
6058 async renderToString ( url ) {
@@ -113,27 +111,27 @@ export default class Renderer {
113111 }
114112
115113 async _loadFile ( filePath ) {
114+ let content
116115 try {
116+ if ( isAbsolutePath ( filePath ) ) {
117+ const res = await fetch ( filePath )
118+ content = await res . text ( )
119+ this . lock = 0
120+ } else {
121+ content = await readFileSync ( filePath , 'utf8' )
122+ this . lock = 0
123+ }
124+ return content
125+ } catch ( e ) {
117126 this . lock = this . lock || 0
118127 if ( ++ this . lock > 10 ) {
119128 this . lock = 0
120129 return
121130 }
122131
123- if ( isAbsolutePath ( filePath ) ) {
124- const res = await fetch ( filePath )
125- return await res . text ( )
126- } else {
127- return readFileSync ( filePath , 'utf8' )
128- }
129- } catch ( e ) {
130132 const fileName = basename ( filePath )
131133 const parentPath = cwd ( filePath , '../..' )
132134
133- if ( this . context . length < parentPath . length ) {
134- throw Error ( `Not found file ${ fileName } ` )
135- }
136-
137135 await this . _loadFile ( cwd ( filePath , '../..' , fileName ) )
138136 }
139137 }
0 commit comments