feat(ssr): add render function
This commit is contained in:
parent
4036bd8388
commit
a0bac30ebb
1 changed files with 10 additions and 0 deletions
|
|
@ -57,6 +57,16 @@ export default class Renderer {
|
||||||
return isAbsolutePath(file) ? file : cwd(`./${file}`)
|
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) {
|
async renderToString(url) {
|
||||||
this.url = url = this.router.parse(url).path
|
this.url = url = this.router.parse(url).path
|
||||||
const {loadSidebar, loadNavbar, coverpage} = this.config
|
const {loadSidebar, loadNavbar, coverpage} = this.config
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue