@ikas/storefront 0.0.25 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,8 @@
1
1
  import * as React from "react";
2
+ import { IkasThemePage } from "../../models/index";
2
3
  declare type Props = {
3
- pageTitle?: string | null;
4
- description?: string | null;
4
+ page?: IkasThemePage;
5
+ pageSpecificDataStr?: string;
5
6
  };
6
7
  export declare const IkasPageHead: React.FC<Props>;
7
8
  export {};
@@ -4,6 +4,7 @@ import { IkasPageComponentPropValue } from "../../utils/index";
4
4
  declare type Props = {
5
5
  propValues: IkasPageComponentPropValue[];
6
6
  page?: IkasThemePage;
7
+ pageSpecificDataStr?: string;
7
8
  };
8
9
  export declare const IkasPage: React.FC<Props>;
9
10
  export {};
package/build/index.es.js CHANGED
@@ -11704,6 +11704,17 @@ var IkasPageDataProvider = /** @class */ (function () {
11704
11704
  var usePageData = propValue.usePageData;
11705
11705
  var _propValue = propValue;
11706
11706
  var productDetail = new IkasProductDetail(_propValue.product, _propValue.selectedVariantValues);
11707
+ var isBrowser = typeof window !== "undefined";
11708
+ if (isBrowser) {
11709
+ var urlParams = new URLSearchParams(window.location.search);
11710
+ var vid_1 = urlParams.get("vid");
11711
+ if (vid_1) {
11712
+ var variant = productDetail.product.variants.find(function (v) { return v.id === vid_1; });
11713
+ if (variant) {
11714
+ productDetail.selectedVariantValues = variant.variantValues;
11715
+ }
11716
+ }
11717
+ }
11707
11718
  pageComponentPropValue.propValues[prop.name] = new IkasProductDetail(productDetail.product, productDetail.selectedVariantValues, usePageData, router);
11708
11719
  };
11709
11720
  IkasPageDataProvider.initLinkPropValue = function (prop, propValue, pageComponentPropValue) {
@@ -18362,7 +18373,7 @@ var IkasCustomerAPI = /** @class */ (function () {
18362
18373
  case 3:
18363
18374
  err_5 = _b.sent();
18364
18375
  console.log(err_5);
18365
- return [3 /*break*/, 4];
18376
+ return [2 /*return*/, false];
18366
18377
  case 4: return [2 /*return*/, true];
18367
18378
  }
18368
18379
  });
@@ -22672,11 +22683,62 @@ var PolicyModal = observer(function (_a) {
22672
22683
  });
22673
22684
 
22674
22685
  var IkasPageHead = observer(function (_a) {
22675
- var pageTitle = _a.pageTitle, description = _a.description;
22686
+ var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr;
22687
+ var schema;
22688
+ if (pageSpecificDataStr && (page === null || page === void 0 ? void 0 : page.type) === IkasThemePageType.PRODUCT) {
22689
+ schema = createProductSchema(pageSpecificDataStr);
22690
+ }
22676
22691
  return (createElement(Head, null,
22677
- createElement("title", null, pageTitle || ""),
22678
- createElement("meta", { name: "description", content: description || "" })));
22679
- });
22692
+ createElement("title", null, (page === null || page === void 0 ? void 0 : page.pageTitle) || ""),
22693
+ createElement("meta", { name: "description", content: (page === null || page === void 0 ? void 0 : page.description) || "" }),
22694
+ !!schema && (createElement("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
22695
+ __html: JSON.stringify(schema),
22696
+ } }))));
22697
+ });
22698
+ function createProductSchema(pageSpecificDataStr) {
22699
+ var _a;
22700
+ var productDetailParsed = JSON.parse(pageSpecificDataStr);
22701
+ var productDetail = new IkasProductDetail(productDetailParsed.product, productDetailParsed.selectedVariantValues);
22702
+ return {
22703
+ "@context": "https://schema.org/",
22704
+ "@type": "Product",
22705
+ name: productDetail.product.name,
22706
+ image: productDetail.selectedVariant.images.map(function (i) { return i.src; }),
22707
+ description: "Sleeker than ACME's Classic Anvil, the Executive Anvil is perfect for the business traveler looking for something to drop from a height.",
22708
+ sku: productDetail.selectedVariant.sku,
22709
+ mpn: "925872",
22710
+ brand: {
22711
+ "@type": "Brand",
22712
+ name: (_a = productDetail.product.brand) === null || _a === void 0 ? void 0 : _a.name,
22713
+ },
22714
+ review: {
22715
+ "@type": "Review",
22716
+ reviewRating: {
22717
+ "@type": "Rating",
22718
+ ratingValue: "4",
22719
+ bestRating: "5",
22720
+ },
22721
+ author: {
22722
+ "@type": "Person",
22723
+ name: "Fred Benson",
22724
+ },
22725
+ },
22726
+ aggregateRating: {
22727
+ "@type": "AggregateRating",
22728
+ ratingValue: "4.4",
22729
+ reviewCount: "89",
22730
+ },
22731
+ offers: {
22732
+ "@type": "Offer",
22733
+ url: "https://example.com/anvil",
22734
+ priceCurrency: productDetail.selectedVariant.price.currency,
22735
+ price: productDetail.selectedVariant.price.finalPrice,
22736
+ priceValidUntil: "2020-11-20",
22737
+ itemCondition: "https://schema.org/UsedCondition",
22738
+ availability: "https://schema.org/InStock",
22739
+ },
22740
+ };
22741
+ }
22680
22742
 
22681
22743
  var IkasCheckoutPage = observer(function (_a) {
22682
22744
  var _b, _c, _d;
@@ -22836,7 +22898,7 @@ var ThemeComponent = observer(function (_a) {
22836
22898
 
22837
22899
  var IkasPage = observer(function (_a) {
22838
22900
  var _b, _c;
22839
- var propValues = _a.propValues, page = _a.page;
22901
+ var propValues = _a.propValues, page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr;
22840
22902
  var renderComponent = function (pageComponent, index) {
22841
22903
  var pageComponentPropValue = propValues.find(function (pv) { return pv.pageComponent.id === pageComponent.id; });
22842
22904
  return (createElement(ThemeComponent, { key: pageComponent.id, index: index, pageComponentPropValue: pageComponentPropValue, pageComponent: pageComponent }));
@@ -22849,7 +22911,7 @@ var IkasPage = observer(function (_a) {
22849
22911
  if (!page)
22850
22912
  return null;
22851
22913
  return (createElement(Fragment, null,
22852
- createElement(IkasPageHead, { pageTitle: page.pageTitle, description: page.description }),
22914
+ createElement(IkasPageHead, { page: page, pageSpecificDataStr: pageSpecificDataStr }),
22853
22915
  createElement("div", { style: pageStyle },
22854
22916
  createElement("div", null,
22855
22917
  headerComponent && renderComponent(headerComponent, -1),
@@ -23347,7 +23409,7 @@ var Page$1 = function (_a) {
23347
23409
  return IkasPageDataProvider.initPropValues(propValuesStr, router);
23348
23410
  });
23349
23411
  handleGTM(page, pageSpecificDataStr);
23350
- return createElement(IkasPage, { page: page, propValues: propValues.get() });
23412
+ return (createElement(IkasPage, { page: page, propValues: propValues.get(), pageSpecificDataStr: pageSpecificDataStr }));
23351
23413
  };
23352
23414
  var index$1 = observer(Page$1);
23353
23415
  var getStaticPaths = function (context) { return __awaiter(void 0, void 0, void 0, function () {
package/build/index.js CHANGED
@@ -11717,6 +11717,17 @@ var IkasPageDataProvider = /** @class */ (function () {
11717
11717
  var usePageData = propValue.usePageData;
11718
11718
  var _propValue = propValue;
11719
11719
  var productDetail = new IkasProductDetail(_propValue.product, _propValue.selectedVariantValues);
11720
+ var isBrowser = typeof window !== "undefined";
11721
+ if (isBrowser) {
11722
+ var urlParams = new URLSearchParams(window.location.search);
11723
+ var vid_1 = urlParams.get("vid");
11724
+ if (vid_1) {
11725
+ var variant = productDetail.product.variants.find(function (v) { return v.id === vid_1; });
11726
+ if (variant) {
11727
+ productDetail.selectedVariantValues = variant.variantValues;
11728
+ }
11729
+ }
11730
+ }
11720
11731
  pageComponentPropValue.propValues[prop.name] = new IkasProductDetail(productDetail.product, productDetail.selectedVariantValues, usePageData, router);
11721
11732
  };
11722
11733
  IkasPageDataProvider.initLinkPropValue = function (prop, propValue, pageComponentPropValue) {
@@ -18346,7 +18357,7 @@ var IkasCustomerAPI = /** @class */ (function () {
18346
18357
  case 3:
18347
18358
  err_5 = _b.sent();
18348
18359
  console.log(err_5);
18349
- return [3 /*break*/, 4];
18360
+ return [2 /*return*/, false];
18350
18361
  case 4: return [2 /*return*/, true];
18351
18362
  }
18352
18363
  });
@@ -22656,11 +22667,62 @@ var PolicyModal = mobxReactLite.observer(function (_a) {
22656
22667
  });
22657
22668
 
22658
22669
  var IkasPageHead = mobxReactLite.observer(function (_a) {
22659
- var pageTitle = _a.pageTitle, description = _a.description;
22670
+ var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr;
22671
+ var schema;
22672
+ if (pageSpecificDataStr && (page === null || page === void 0 ? void 0 : page.type) === exports.IkasThemePageType.PRODUCT) {
22673
+ schema = createProductSchema(pageSpecificDataStr);
22674
+ }
22660
22675
  return (React.createElement(Head__default['default'], null,
22661
- React.createElement("title", null, pageTitle || ""),
22662
- React.createElement("meta", { name: "description", content: description || "" })));
22663
- });
22676
+ React.createElement("title", null, (page === null || page === void 0 ? void 0 : page.pageTitle) || ""),
22677
+ React.createElement("meta", { name: "description", content: (page === null || page === void 0 ? void 0 : page.description) || "" }),
22678
+ !!schema && (React.createElement("script", { type: "application/ld+json", dangerouslySetInnerHTML: {
22679
+ __html: JSON.stringify(schema),
22680
+ } }))));
22681
+ });
22682
+ function createProductSchema(pageSpecificDataStr) {
22683
+ var _a;
22684
+ var productDetailParsed = JSON.parse(pageSpecificDataStr);
22685
+ var productDetail = new IkasProductDetail(productDetailParsed.product, productDetailParsed.selectedVariantValues);
22686
+ return {
22687
+ "@context": "https://schema.org/",
22688
+ "@type": "Product",
22689
+ name: productDetail.product.name,
22690
+ image: productDetail.selectedVariant.images.map(function (i) { return i.src; }),
22691
+ description: "Sleeker than ACME's Classic Anvil, the Executive Anvil is perfect for the business traveler looking for something to drop from a height.",
22692
+ sku: productDetail.selectedVariant.sku,
22693
+ mpn: "925872",
22694
+ brand: {
22695
+ "@type": "Brand",
22696
+ name: (_a = productDetail.product.brand) === null || _a === void 0 ? void 0 : _a.name,
22697
+ },
22698
+ review: {
22699
+ "@type": "Review",
22700
+ reviewRating: {
22701
+ "@type": "Rating",
22702
+ ratingValue: "4",
22703
+ bestRating: "5",
22704
+ },
22705
+ author: {
22706
+ "@type": "Person",
22707
+ name: "Fred Benson",
22708
+ },
22709
+ },
22710
+ aggregateRating: {
22711
+ "@type": "AggregateRating",
22712
+ ratingValue: "4.4",
22713
+ reviewCount: "89",
22714
+ },
22715
+ offers: {
22716
+ "@type": "Offer",
22717
+ url: "https://example.com/anvil",
22718
+ priceCurrency: productDetail.selectedVariant.price.currency,
22719
+ price: productDetail.selectedVariant.price.finalPrice,
22720
+ priceValidUntil: "2020-11-20",
22721
+ itemCondition: "https://schema.org/UsedCondition",
22722
+ availability: "https://schema.org/InStock",
22723
+ },
22724
+ };
22725
+ }
22664
22726
 
22665
22727
  var IkasCheckoutPage = mobxReactLite.observer(function (_a) {
22666
22728
  var _b, _c, _d;
@@ -22820,7 +22882,7 @@ var ThemeComponent = mobxReactLite.observer(function (_a) {
22820
22882
 
22821
22883
  var IkasPage = mobxReactLite.observer(function (_a) {
22822
22884
  var _b, _c;
22823
- var propValues = _a.propValues, page = _a.page;
22885
+ var propValues = _a.propValues, page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr;
22824
22886
  var renderComponent = function (pageComponent, index) {
22825
22887
  var pageComponentPropValue = propValues.find(function (pv) { return pv.pageComponent.id === pageComponent.id; });
22826
22888
  return (React.createElement(ThemeComponent, { key: pageComponent.id, index: index, pageComponentPropValue: pageComponentPropValue, pageComponent: pageComponent }));
@@ -22833,7 +22895,7 @@ var IkasPage = mobxReactLite.observer(function (_a) {
22833
22895
  if (!page)
22834
22896
  return null;
22835
22897
  return (React.createElement(React.Fragment, null,
22836
- React.createElement(IkasPageHead, { pageTitle: page.pageTitle, description: page.description }),
22898
+ React.createElement(IkasPageHead, { page: page, pageSpecificDataStr: pageSpecificDataStr }),
22837
22899
  React.createElement("div", { style: pageStyle },
22838
22900
  React.createElement("div", null,
22839
22901
  headerComponent && renderComponent(headerComponent, -1),
@@ -23331,7 +23393,7 @@ var Page$1 = function (_a) {
23331
23393
  return IkasPageDataProvider.initPropValues(propValuesStr, router$1);
23332
23394
  });
23333
23395
  handleGTM(page, pageSpecificDataStr);
23334
- return React.createElement(IkasPage, { page: page, propValues: propValues.get() });
23396
+ return (React.createElement(IkasPage, { page: page, propValues: propValues.get(), pageSpecificDataStr: pageSpecificDataStr }));
23335
23397
  };
23336
23398
  var index$1 = mobxReactLite.observer(Page$1);
23337
23399
  var getStaticPaths = function (context) { return __awaiter(void 0, void 0, void 0, function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",