diff --git a/src/core/schemas/Organization.js b/src/core/schemas/Organization.js new file mode 100644 index 0000000..0e58bfb --- /dev/null +++ b/src/core/schemas/Organization.js @@ -0,0 +1,18 @@ +import JSONLDAbstractNode from '../JSONLDAbstractNode'; + +class Organization extends JSONLDAbstractNode { + getJSON(isFirstChildNode = false, schema) { + const parseChildren = super.parseChildren(); + const details = { + '@type': 'Organization', + ...schema + } + return isFirstChildNode ? + Object.assign(details, ...parseChildren) : + Object.assign({ + brand: details + }, ...parseChildren); + } +} + +export default Organization; diff --git a/src/core/schemas/PostalAddress.js b/src/core/schemas/PostalAddress.js new file mode 100644 index 0000000..407f432 --- /dev/null +++ b/src/core/schemas/PostalAddress.js @@ -0,0 +1,18 @@ +import JSONLDAbstractNode from '../JSONLDAbstractNode'; + +class PostalAddress extends JSONLDAbstractNode { + getJSON(isFirstChildNode = false, schema) { + const parseChildren = super.parseChildren(); + const details = { + '@type': 'PostalAddress', + ...schema + } + return isFirstChildNode ? + Object.assign(details, ...parseChildren) : + Object.assign({ + address: details + }, ...parseChildren); + } +} + +export default PostalAddress; diff --git a/src/core/schemas/index.js b/src/core/schemas/index.js index 969e9f6..7b938fe 100644 --- a/src/core/schemas/index.js +++ b/src/core/schemas/index.js @@ -6,8 +6,12 @@ export { default as Location } from './Location'; export { default as Product } from './Product'; export { default as Rating } from './Rating'; export { default as Review } from './Review'; +export { default as PostalAddress } from './PostalAddress'; +export { default as Organization } from './Organization'; export { default as Reviews } from './Reviews'; export { default as ItemReviewed } from './ItemReviewed'; export { default as Question } from './Question'; export { default as Answer } from './Answer'; export { default as Graph } from './Graph'; + + diff --git a/src/example/containers/Example.js b/src/example/containers/Example.js index bc7ebbc..4ebd18d 100644 --- a/src/example/containers/Example.js +++ b/src/example/containers/Example.js @@ -2,17 +2,20 @@ import React, { PureComponent } from 'react'; import styles from './Example.scss'; import { JSONLD, + AggregateRating, Graph, Product, ItemReviewed, + GenericCollection, Review, Author, Location, Rating, - Generic + Generic, + Organization, + PostalAddress } from 'react-structured-data'; - class Example extends PureComponent { render() { return ( @@ -64,6 +67,17 @@ class Example extends PureComponent { + + + + + );