From c670b25addc39a1b8a7927b42e70fc3f0c6fad4c Mon Sep 17 00:00:00 2001 From: Declan de Wet Date: Thu, 3 Nov 2016 08:52:16 +0200 Subject: [PATCH] fix zombie base tag + document supported props --- README.md | 156 +++++++++++++++++++++++++++-- src/client/updateClientMetaInfo.js | 4 +- 2 files changed, 150 insertions(+), 10 deletions(-) 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 `