feat(ssr): add render function

This commit is contained in:
liqingwei
2019-03-31 14:34:14 +08:00
committed by cinwell.li
parent 4036bd8388
commit a0bac30ebb
+10
View File
@@ -57,6 +57,16 @@ export default class Renderer {
return isAbsolutePath(file) ? file : cwd(`./${file}`)
}
async render(url) {
const content = await this.renderToString(url)
return {
content,
url: this.router.parse(url).path,
path: this._getPath(url)
}
}
async renderToString(url) {
this.url = url = this.router.parse(url).path
const {loadSidebar, loadNavbar, coverpage} = this.config