From f65f3607983cdbbd19deb72cdfc1495cdb833539 Mon Sep 17 00:00:00 2001 From: "gergo.bogdan@accedo.tv" Date: Sun, 1 Dec 2019 18:56:54 +0100 Subject: [PATCH 1/3] added Organization and PostalAddress types --- src/core/schemas/Organization.js | 18 ++++++++++++++++++ src/core/schemas/PostalAddress.js | 18 ++++++++++++++++++ src/core/schemas/index.js | 4 ++++ 3 files changed, 40 insertions(+) create mode 100644 src/core/schemas/Organization.js create mode 100644 src/core/schemas/PostalAddress.js 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'; + + From af4183827cd8a1100b4f61a31b8b8501bae53b6f Mon Sep 17 00:00:00 2001 From: "gergo.bogdan@accedo.tv" Date: Sun, 1 Dec 2019 18:57:46 +0100 Subject: [PATCH 2/3] updated example to include an Organization --- src/example/containers/Example.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/example/containers/Example.js b/src/example/containers/Example.js index bc7ebbc..a88639a 100644 --- a/src/example/containers/Example.js +++ b/src/example/containers/Example.js @@ -2,16 +2,20 @@ import React, { PureComponent } from 'react'; import styles from './Example.scss'; import { JSONLD, + AggregateRating, Graph, Product, ItemReviewed, + GenericCollection, Review, Author, Location, Rating, - Generic -} from 'react-structured-data'; - + Generic, + Organization, + PostalAddress +//} from 'react-structured-data'; +} from '../../core/index'; class Example extends PureComponent { render() { @@ -64,6 +68,17 @@ class Example extends PureComponent { + + + + + ); From adf9412eaa0ac5b415d6b6b98e2033f3f883bbfa Mon Sep 17 00:00:00 2001 From: "gergo.bogdan@accedo.tv" Date: Sun, 1 Dec 2019 19:00:57 +0100 Subject: [PATCH 3/3] updated the examples --- src/example/containers/Example.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/example/containers/Example.js b/src/example/containers/Example.js index a88639a..4ebd18d 100644 --- a/src/example/containers/Example.js +++ b/src/example/containers/Example.js @@ -14,8 +14,7 @@ import { Generic, Organization, PostalAddress -//} from 'react-structured-data'; -} from '../../core/index'; +} from 'react-structured-data'; class Example extends PureComponent { render() {