react-structured-data
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -19,2 +19,4 @@ 'use strict'; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
@@ -40,7 +42,10 @@ | ||
value: function getJSON() { | ||
var isFirstChildNode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; | ||
var parseChildren = _get(ChildNode.prototype.__proto__ || Object.getPrototypeOf(ChildNode.prototype), 'parseChildren', this).call(this); | ||
var schema = this.props.schema; | ||
var details = { | ||
'@type': this.props.jsonldtype | ||
}; | ||
return _extends.apply(undefined, [details, this.props.schema].concat(_toConsumableArray(parseChildren))); | ||
return isFirstChildNode ? _extends.apply(undefined, [_extends({}, details, schema)].concat(_toConsumableArray(parseChildren))) : _extends(_defineProperty({}, this.props.id, _extends({}, details, schema, parseChildren))); | ||
} | ||
@@ -47,0 +52,0 @@ }]); |
{ | ||
"name": "react-structured-data", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Declarative JSON-LD Structured Data for ReactJS Apps", | ||
@@ -21,2 +21,6 @@ "author": "Ben Taylor <benlt105@gmail.com>", | ||
], | ||
"dependencies": { | ||
"react": "^16.2.0", | ||
"prop-types": "^15.6.0" | ||
}, | ||
"devDependencies": { | ||
@@ -63,4 +67,2 @@ "autoprefixer": "7.1.6", | ||
"react-dom": "^16.2.0", | ||
"react-structured-data": "./react-structured-data-0.0.1.tgz", | ||
"react-syntax-highlighter": "^6.1.0", | ||
"sass-loader": "^6.0.6", | ||
@@ -67,0 +69,0 @@ "style-loader": "0.19.0", |
@@ -9,7 +9,7 @@ # React Structured Data | ||
run `yarn add react-structured-data` | ||
`yarn add react-structured-data` | ||
### NPM | ||
run `npm install react-structured-data --save` | ||
`npm install react-structured-data --save` | ||
@@ -110,2 +110,20 @@ ## Code Example | ||
If you would like to use a component that is not listed, simply use the Generic component and add the prop jsonldtype. | ||
Generic and GenericCollection allow you to add your own structured data type. | ||
For example, If Review preset didn't exist, you could write: | ||
``` | ||
<JSONLD> | ||
<Generic id="review" jsonldtype="Review" schema={{name: "It is awesome", reviewBody: "This is great!"}}> | ||
<Generic id="itemReviewed" jsonldtype="Product" schema={{"@id":"product-x"}} /> | ||
<Generic id="author" jsonldtype="Person" schema={{name: "Cool Carl"}}/> | ||
<Generic id="locationCreated" jsonldtype="AdministrativeArea" schema={{name: "Chicago, IL"}}/> | ||
</Generic> | ||
</JSONLD> | ||
``` | ||
This may seem not as ideal as using the presets, but this allows completely customizable structured data. | ||
There will also be more preset components to come in future releases to make implementation easier so stay tuned! | ||
### Structured Data and Schema.org | ||
@@ -112,0 +130,0 @@ |
65088
48
686
138
2
+ Addedprop-types@^15.6.0
+ Addedreact@^16.2.0
+ Addedjs-tokens@4.0.0(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedprop-types@15.8.1(transitive)
+ Addedreact@16.14.0(transitive)
+ Addedreact-is@16.13.1(transitive)