diff --git a/README.md b/README.md
index 35b5140..f63a5a0 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
- Manage page meta info in Vue 2.0 components. SSR + Streaming supported. Inspired by react-helmet
+ Manage page meta info in Vue 2.0 components. SSR + Streaming supported. Inspired by react-helmet .
@@ -59,6 +59,12 @@
- [`titleTemplate` (String)](#titletemplate-string)
- [`htmlAttrs` (Object)](#htmlattrs-object)
- [`bodyAttrs` (Object)](#bodyattrs-object)
+ - [`base` (Object)](#base-object)
+ - [`meta` ([Object])](#meta-object)
+ - [`link` ([Object])](#link-object)
+ - [`style` ([Object])](#style-object)
+ - [`script` ([Object])](#script-object)
+ - [`noscript` ([Object])](#noscript-object)
- [How `metaInfo` is Resolved](#how-metainfo-is-resolved)
- [Performance](#performance)
- [How to prevent the update on the initial page render](#how-to-prevent-the-update-on-the-initial-page-render)
@@ -150,13 +156,26 @@ app.get('*', (req, res) => {
const context = { url: req.url }
renderer.renderToString(context, (error, html) => {
if (error) return res.send(error.stack)
- const { meta } = context
- const { title, htmlAttrs, bodyAttrs } = meta.inject()
+ const {
+ title,
+ htmlAttrs,
+ bodyAttrs,
+ link,
+ style,
+ script,
+ noscript,
+ meta
+ } = context.meta.inject()
return res.send(`
+ ${meta.text()}
${title.text()}
+ ${link.text()}
+ ${style.text()}
+ ${script.text()}
+ ${noscript.text()}
${html}
@@ -182,13 +201,26 @@ app.get('*', (req, res) => {
renderStream.on('data', (chunk) => {
if (firstChunk) {
firstChunk = false
- const { meta } = context
- const { title, htmlAttrs, bodyAttrs } = meta.inject()
+ const {
+ title,
+ htmlAttrs,
+ bodyAttrs,
+ link,
+ style,
+ script,
+ noscript,
+ meta
+ } = context.meta.inject()
res.write(`
+ ${meta.text()}
${title.text()}
+ ${link.text()}
+ ${style.text()}
+ ${script.text()}
+ ${noscript.text()}
`)
@@ -343,6 +375,116 @@ Each **key:value** maps to the equivalent **attribute:value** of the `` el
Foo Bar
```
+#### `base` (Object)
+
+Maps to a newly-created ` ` element, where object properties map to attributes.
+
+```js
+{
+ metaInfo: {
+ base: { target: '_blank', href: '/' }
+ }
+}
+```
+
+```html
+
+```
+
+#### `meta` ([Object])
+
+Each item in the array maps to a newly-created ` ` element, where object properties map to attributes.
+
+```js
+{
+ metaInfo: {
+ meta: [
+ { charset: 'utf-8' },
+ { name: 'viewport', content: 'width=device-width, initial-scale=1' }
+ ]
+ }
+}
+```
+
+```html
+
+
+```
+
+#### `link` ([Object])
+
+Each item in the array maps to a newly-created ` ` element, where object properties map to attributes.
+
+```js
+{
+ metaInfo: {
+ link: [
+ { rel: 'stylesheet', src: '/css/index.css' },
+ { rel: 'favicon', src: 'favicon.ico' }
+ ]
+ }
+}
+```
+
+```html
+
+
+```
+
+#### `style` ([Object])
+
+Each item in the array maps to a newly-created `
+```
+
+#### `script` ([Object])
+
+Each item in the array maps to a newly-created `
+```
+
+#### `noscript` ([Object])
+
+Each item in the array maps to a newly-created `` element, where object properties map to attributes.
+
+```js
+{
+ metaInfo: {
+ nosript: [
+ { innerHTML: 'This website requires JavaScript.' }
+ ]
+ }
+}
+```
+
+```html
+This website requires JavaScript.
+```
+
### How `metaInfo` is Resolved
You can define a `metaInfo` property on any component in the tree. Child components that have `metaInfo` will recursively merge their `metaInfo` into the parent context, overwriting any duplicate properties. To better illustrate, consider this component heirarchy:
@@ -379,7 +521,7 @@ Add the `data-vue-meta-server-rendered` attribute to the `` tag on the ser
Here are some answers to some frequently asked questions.
## How do I use component data in `metaInfo`?
-Specify a function instead of a property.
+Specify a function instead of an object. It will need to return the same type as its definition.
**BlogPost.vue:**
```html
@@ -405,7 +547,7 @@ Specify a function instead of a property.
```
## How do I use component props in `metaInfo`?
-The same way you use data.
+The same way you use data - specify a function instead of an object. It will need to return the same type as its definition.
**BlogPostWrapper.vue**
```html
diff --git a/src/client/updateClientMetaInfo.js b/src/client/updateClientMetaInfo.js
index 5978cfd..5efe7cd 100644
--- a/src/client/updateClientMetaInfo.js
+++ b/src/client/updateClientMetaInfo.js
@@ -40,9 +40,7 @@ export default function updateClientMetaInfo (newInfo, $root) {
// update tags
for (let i = 0, len = tags.length; i < len; i++) {
const tag = tags[i]
- if (newInfo[tag]) {
- updateTags(tag, newInfo[tag], headTag)
- }
+ updateTags(tag, newInfo[tag], headTag)
}
} else {
htmlTag.removeAttribute(SERVER_RENDERED_ATTRIBUTE)