mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-22 08:50:33 +03:00
add doc for inBody
This commit is contained in:
@@ -193,6 +193,7 @@ app.get('*', (req, res) => {
|
|||||||
const context = { url: req.url }
|
const context = { url: req.url }
|
||||||
renderer.renderToString(context, (error, html) => {
|
renderer.renderToString(context, (error, html) => {
|
||||||
if (error) return res.send(error.stack)
|
if (error) return res.send(error.stack)
|
||||||
|
const bodyOpt = { inBody: true }
|
||||||
const {
|
const {
|
||||||
title, htmlAttrs, bodyAttrs, link, style, script, noscript, meta
|
title, htmlAttrs, bodyAttrs, link, style, script, noscript, meta
|
||||||
} = context.meta.inject()
|
} = context.meta.inject()
|
||||||
@@ -211,6 +212,7 @@ app.get('*', (req, res) => {
|
|||||||
${html}
|
${html}
|
||||||
<script src="/assets/vendor.bundle.js"></script>
|
<script src="/assets/vendor.bundle.js"></script>
|
||||||
<script src="/assets/client.bundle.js"></script>
|
<script src="/assets/client.bundle.js"></script>
|
||||||
|
${script.text(bodyOpt)}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`)
|
`)
|
||||||
@@ -228,6 +230,7 @@ app.get('*', (req, res) => {
|
|||||||
const context = { url: req.url }
|
const context = { url: req.url }
|
||||||
const renderStream = renderer.renderToStream(context)
|
const renderStream = renderer.renderToStream(context)
|
||||||
renderStream.once('data', () => {
|
renderStream.once('data', () => {
|
||||||
|
const bodyOpt = { inBody: true }
|
||||||
const {
|
const {
|
||||||
title, htmlAttrs, bodyAttrs, link, style, script, noscript, meta
|
title, htmlAttrs, bodyAttrs, link, style, script, noscript, meta
|
||||||
} = context.meta.inject()
|
} = context.meta.inject()
|
||||||
@@ -252,6 +255,7 @@ app.get('*', (req, res) => {
|
|||||||
res.end(`
|
res.end(`
|
||||||
<script src="/assets/vendor.bundle.js"></script>
|
<script src="/assets/vendor.bundle.js"></script>
|
||||||
<script src="/assets/client.bundle.js"></script>
|
<script src="/assets/client.bundle.js"></script>
|
||||||
|
${script.text(bodyOpt)}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</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>
|
<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])
|
#### `noscript` ([Object])
|
||||||
|
|
||||||
Each item in the array maps to a newly-created `<noscript>` element, where object properties map to attributes.
|
Each item in the array maps to a newly-created `<noscript>` element, where object properties map to attributes.
|
||||||
|
|||||||
Reference in New Issue
Block a user