2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-25 12:40:34 +03:00

better readme example

This commit is contained in:
Declan de Wet
2016-11-08 05:03:42 +02:00
parent 6ad56ec73e
commit d426c05f47
+5 -21
View File
@@ -172,14 +172,7 @@ app.get('*', (req, res) => {
renderer.renderToString(context, (error, html) => {
if (error) return res.send(error.stack)
const {
title,
htmlAttrs,
bodyAttrs,
link,
style,
script,
noscript,
meta
title, htmlAttrs, bodyAttrs, link, style, script, noscript, meta
} = context.meta.inject()
return res.send(`
<!doctype html>
@@ -212,19 +205,9 @@ A little more complex, but well worth it, is to instead stream your response. `v
app.get('*', (req, res) => {
const context = { url: req.url }
const renderStream = renderer.renderToStream(context)
let firstChunk = true
renderStream.on('data', (chunk) => {
if (firstChunk) {
firstChunk = false
renderStream.once('data', () => {
const {
title,
htmlAttrs,
bodyAttrs,
link,
style,
script,
noscript,
meta
title, htmlAttrs, bodyAttrs, link, style, script, noscript, meta
} = context.meta.inject()
res.write(`
<!doctype html>
@@ -239,7 +222,8 @@ app.get('*', (req, res) => {
</head>
<body ${bodyAttrs.text()}>
`)
}
})
renderStream.on('data', (chunk) => {
res.write(chunk)
})
renderStream.on('end', () => {