react-document-meta
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -48,3 +48,5 @@ 'use strict'; | ||
// ograph( props ); | ||
if (props.auto) { | ||
autoProps(props); | ||
} | ||
@@ -54,21 +56,30 @@ return props; | ||
function autoProps(props) { | ||
if (props.auto.ograph === true) { | ||
ograph(props); | ||
} | ||
return props; | ||
} | ||
function ograph(p) { | ||
/* const og = p.ograph; | ||
if ( og ) { | ||
if ( p.title && !og.title ) { | ||
p.tags.push({ property: 'og:title', content: p.title }); | ||
} | ||
if ( p.description && !og.description ) { | ||
p.tags.push({ property: 'og:description', content: p.description }); | ||
} | ||
if ( p.canonical && !og.url ) { | ||
p.tags.push({ property: 'og:url', content: p.canonical }); | ||
} | ||
Object.keys(og).reduce(( acc, key ) => { | ||
acc.push({ property: 'og:'+key, content: og[key] }); | ||
return acc; | ||
}, p.tags); | ||
if (!p.meta) { | ||
p.meta = {}; | ||
} | ||
if (!p.meta.property) { | ||
p.meta.property = {}; | ||
} | ||
var group = p.meta.property; | ||
if (group) { | ||
if (p.title && !group['og:title']) { | ||
group['og:title'] = p.title; | ||
} | ||
*/ | ||
if (p.description && !group['og:description']) { | ||
group['og:description'] = p.description; | ||
} | ||
// if ( p.canonical && !group['og:url'] ) { | ||
// group['og:url'] = p.canonical; | ||
// } | ||
} | ||
return p; | ||
@@ -188,3 +199,4 @@ } | ||
meta: _React2['default'].PropTypes.objectOf(_React2['default'].PropTypes.objectOf(_React2['default'].PropTypes.string)), | ||
link: _React2['default'].PropTypes.objectOf(_React2['default'].PropTypes.objectOf(_React2['default'].PropTypes.string)) | ||
link: _React2['default'].PropTypes.objectOf(_React2['default'].PropTypes.objectOf(_React2['default'].PropTypes.string)), | ||
auto: _React2['default'].PropTypes.objectOf(_React2['default'].PropTypes.bool) | ||
}, | ||
@@ -191,0 +203,0 @@ |
@@ -34,3 +34,5 @@ import React from 'react'; | ||
// ograph( props ); | ||
if (props.auto) { | ||
autoProps( props ); | ||
} | ||
@@ -40,21 +42,30 @@ return props; | ||
function autoProps ( props ) { | ||
if (props.auto.ograph === true) { | ||
ograph(props); | ||
} | ||
return props; | ||
} | ||
function ograph ( p ) { | ||
/* const og = p.ograph; | ||
if ( og ) { | ||
if ( p.title && !og.title ) { | ||
p.tags.push({ property: 'og:title', content: p.title }); | ||
if (!p.meta) { | ||
p.meta = {}; | ||
} | ||
if (!p.meta.property) { | ||
p.meta.property = {}; | ||
} | ||
const group = p.meta.property; | ||
if ( group ) { | ||
if ( p.title && !group['og:title'] ) { | ||
group['og:title'] = p.title; | ||
} | ||
if ( p.description && !og.description ) { | ||
p.tags.push({ property: 'og:description', content: p.description }); | ||
if ( p.description && !group['og:description'] ) { | ||
group['og:description'] = p.description; | ||
} | ||
if ( p.canonical && !og.url ) { | ||
p.tags.push({ property: 'og:url', content: p.canonical }); | ||
} | ||
Object.keys(og).reduce(( acc, key ) => { | ||
acc.push({ property: 'og:'+key, content: og[key] }); | ||
return acc; | ||
}, p.tags); | ||
// if ( p.canonical && !group['og:url'] ) { | ||
// group['og:url'] = p.canonical; | ||
// } | ||
} | ||
*/ | ||
return p; | ||
@@ -163,3 +174,4 @@ } | ||
meta: React.PropTypes.objectOf(React.PropTypes.objectOf(React.PropTypes.string)), | ||
link: React.PropTypes.objectOf(React.PropTypes.objectOf(React.PropTypes.string)) | ||
link: React.PropTypes.objectOf(React.PropTypes.objectOf(React.PropTypes.string)), | ||
auto: React.PropTypes.objectOf(React.PropTypes.bool) | ||
}, | ||
@@ -166,0 +178,0 @@ |
{ | ||
"name": "react-document-meta", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Declarative, nested and stateful HTML document meta tags for React", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14473
364