Skip to content

Commit f4649d1

Browse files
committed
Add append html callback
1 parent 47188fc commit f4649d1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

packages/vue-ssr/server/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,18 @@ onPageLoad(sink => new Promise((resolve, reject) => {
123123
// })
124124
// // sink.appendToHead(`<script type="text/inject-data">${encodeURIComponent(injectData)}</script>`)
125125

126-
const script = (result.js && `<script type="text/javascript">${result.js}</script>`) || ''
126+
let appendHtml
127+
if (typeof result.appendHtml === "function") appendHtml = result.appendHtml()
128+
129+
const head = ((appendHtml && appendHtml.head) || result.head) || ''
130+
const body = ((appendHtml && appendHtml.body) || result.body) || ''
131+
const js = ((appendHtml && appendHtml.js) || result.js) || ''
132+
133+
const script = js && `<script type="text/javascript">${js}</script>`
127134

128135
sink.renderIntoElementById(VueSSR.outlet, html)
129-
sink.appendToBody(script)
136+
sink.appendToHead(head)
137+
sink.appendToBody([body, script])
130138

131139
resolve()
132140
},

0 commit comments

Comments
 (0)