2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-05 02:12:24 +03:00

add doc for inBody

This commit is contained in:
Clark Du
2017-11-03 11:14:49 +08:00
parent 8602d5060c
commit 5dd7c9fbe6
+16
View File
@@ -193,6 +193,7 @@ app.get('*', (req, res) => {
const context = { url: req.url }
renderer.renderToString(context, (error, html) => {
if (error) return res.send(error.stack)
const bodyOpt = { inBody: true }
const {
title, htmlAttrs, bodyAttrs, link, style, script, noscript, meta
} = context.meta.inject()
@@ -211,6 +212,7 @@ app.get('*', (req, res) => {
${html}
<script src="/assets/vendor.bundle.js"></script>
<script src="/assets/client.bundle.js"></script>
${script.text(bodyOpt)}
</body>
</html>
`)
@@ -228,6 +230,7 @@ app.get('*', (req, res) => {
const context = { url: req.url }
const renderStream = renderer.renderToStream(context)
renderStream.once('data', () => {
const bodyOpt = { inBody: true }
const {
title, htmlAttrs, bodyAttrs, link, style, script, noscript, meta
} = context.meta.inject()
@@ -252,6 +255,7 @@ app.get('*', (req, res) => {
res.end(`
<script src="/assets/vendor.bundle.js"></script>
<script src="/assets/client.bundle.js"></script>
${script.text(bodyOpt)}
</body>
</html>
`)
@@ -497,6 +501,18 @@ Each item in the array maps to a newly-created `<script>` element, where object
<script type="application/ld+json">{ "@context": "http://schema.org" }</script>
```
If your browser doesn't support `defer` or any other reason, you want to put `<script>` before `</body>`, use `inBody`.
```js
{
metaInfo: {
script: [
{ innerHTML: 'console.log("I am in body");', type: 'text/javascript', inBody: true }
]
}
}
```
#### `noscript` ([Object])
Each item in the array maps to a newly-created `<noscript>` element, where object properties map to attributes.