@shop-on/theme-react 0.6.0 → 0.7.0
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.
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/merchant-return-policy-ld.d.ts +17 -0
- package/dist/merchant-return-policy-ld.js +21 -0
- package/dist/organization-json-ld.d.ts +19 -0
- package/dist/organization-json-ld.js +25 -0
- package/dist/product-json-ld.d.ts +4 -0
- package/dist/product-json-ld.js +3 -0
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ import { BreadcrumbJsonLd, BreadcrumbJsonLdProps } from "./breadcrumb-json-ld.js
|
|
|
3
3
|
import { EditorSelectedItem, parseSelected, readClickTarget, sameItem } from "./editor-preview-bridge-utils.js";
|
|
4
4
|
import { EditorPreviewBridge } from "./editor-preview-bridge.js";
|
|
5
5
|
import { FaqJsonLd, FaqJsonLdItem, FaqJsonLdProps } from "./faq-json-ld.js";
|
|
6
|
+
import { OrganizationJsonLd, OrganizationJsonLdProps } from "./organization-json-ld.js";
|
|
6
7
|
import { ProductJsonLd, ProductJsonLdProps } from "./product-json-ld.js";
|
|
7
8
|
import { WebsiteJsonLd, WebsiteJsonLdProps } from "./website-json-ld.js";
|
|
8
9
|
import { PreviewSearch, bouncePreviewToNotFound } from "./preview-guard.js";
|
|
9
10
|
import { retainPreviewSearch } from "./preview-search-middleware.js";
|
|
10
11
|
import { ArticleSchemaSource, BlockInstance, ClosestScope, LayoutComponent, ProductSchemaSource, SectionGroupConfig, TemplateJSON, TemplateRendererInstance, TemplateRendererLoaders, TemplateSeoSource, createTemplateRenderer, withClosestOverlays } from "./template-renderer.js";
|
|
11
12
|
import { useIsoLayoutEffect } from "./use-iso-layout-effect.js";
|
|
12
|
-
export { ArticleJsonLd, type ArticleJsonLdProps, type ArticleSchemaSource, type BlockInstance, BreadcrumbJsonLd, type BreadcrumbJsonLdProps, ClosestScope, EditorPreviewBridge, type EditorSelectedItem, FaqJsonLd, type FaqJsonLdItem, type FaqJsonLdProps, type LayoutComponent, type PreviewSearch, ProductJsonLd, type ProductJsonLdProps, type ProductSchemaSource, type SectionGroupConfig, type TemplateJSON, type TemplateRendererInstance, type TemplateRendererLoaders, type TemplateSeoSource, WebsiteJsonLd, type WebsiteJsonLdProps, bouncePreviewToNotFound, createTemplateRenderer, parseSelected, readClickTarget, retainPreviewSearch, sameItem, useIsoLayoutEffect, withClosestOverlays };
|
|
13
|
+
export { ArticleJsonLd, type ArticleJsonLdProps, type ArticleSchemaSource, type BlockInstance, BreadcrumbJsonLd, type BreadcrumbJsonLdProps, ClosestScope, EditorPreviewBridge, type EditorSelectedItem, FaqJsonLd, type FaqJsonLdItem, type FaqJsonLdProps, type LayoutComponent, OrganizationJsonLd, type OrganizationJsonLdProps, type PreviewSearch, ProductJsonLd, type ProductJsonLdProps, type ProductSchemaSource, type SectionGroupConfig, type TemplateJSON, type TemplateRendererInstance, type TemplateRendererLoaders, type TemplateSeoSource, WebsiteJsonLd, type WebsiteJsonLdProps, bouncePreviewToNotFound, createTemplateRenderer, parseSelected, readClickTarget, retainPreviewSearch, sameItem, useIsoLayoutEffect, withClosestOverlays };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ArticleJsonLd } from "./article-json-ld.js";
|
|
2
2
|
import { BreadcrumbJsonLd } from "./breadcrumb-json-ld.js";
|
|
3
3
|
import { FaqJsonLd } from "./faq-json-ld.js";
|
|
4
|
+
import { OrganizationJsonLd } from "./organization-json-ld.js";
|
|
4
5
|
import { ProductJsonLd } from "./product-json-ld.js";
|
|
5
6
|
import { WebsiteJsonLd } from "./website-json-ld.js";
|
|
6
7
|
import { parseSelected, readClickTarget, sameItem } from "./editor-preview-bridge-utils.js";
|
|
@@ -9,4 +10,4 @@ import { bouncePreviewToNotFound } from "./preview-guard.js";
|
|
|
9
10
|
import { retainPreviewSearch } from "./preview-search-middleware.js";
|
|
10
11
|
import { ClosestScope, createTemplateRenderer, withClosestOverlays } from "./template-renderer.js";
|
|
11
12
|
import { useIsoLayoutEffect } from "./use-iso-layout-effect.js";
|
|
12
|
-
export { ArticleJsonLd, BreadcrumbJsonLd, ClosestScope, EditorPreviewBridge, FaqJsonLd, ProductJsonLd, WebsiteJsonLd, bouncePreviewToNotFound, createTemplateRenderer, parseSelected, readClickTarget, retainPreviewSearch, sameItem, useIsoLayoutEffect, withClosestOverlays };
|
|
13
|
+
export { ArticleJsonLd, BreadcrumbJsonLd, ClosestScope, EditorPreviewBridge, FaqJsonLd, OrganizationJsonLd, ProductJsonLd, WebsiteJsonLd, bouncePreviewToNotFound, createTemplateRenderer, parseSelected, readClickTarget, retainPreviewSearch, sameItem, useIsoLayoutEffect, withClosestOverlays };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "@shop-on/theme-runtime/template-types";
|
|
2
|
+
//#region src/merchant-return-policy-ld.d.ts
|
|
3
|
+
export interface JsonLdMerchantReturnPolicy {
|
|
4
|
+
"@type": "MerchantReturnPolicy";
|
|
5
|
+
applicableCountry: string;
|
|
6
|
+
returnPolicyCategory: string;
|
|
7
|
+
merchantReturnDays?: number;
|
|
8
|
+
returnFees?: string;
|
|
9
|
+
returnShippingFeesAmount?: {
|
|
10
|
+
"@type": "MonetaryAmount";
|
|
11
|
+
value: number;
|
|
12
|
+
currency: string;
|
|
13
|
+
};
|
|
14
|
+
restockingFee?: number;
|
|
15
|
+
merchantReturnLink?: string;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/merchant-return-policy-ld.ts
|
|
2
|
+
const SCHEMA = "https://schema.org/";
|
|
3
|
+
function buildReturnPolicyLd(src) {
|
|
4
|
+
const ld = {
|
|
5
|
+
"@type": "MerchantReturnPolicy",
|
|
6
|
+
applicableCountry: src.country,
|
|
7
|
+
returnPolicyCategory: `${SCHEMA}MerchantReturn${src.category}`
|
|
8
|
+
};
|
|
9
|
+
if (src.days) ld.merchantReturnDays = src.days;
|
|
10
|
+
if (src.fees) ld.returnFees = `${SCHEMA}${src.fees}`;
|
|
11
|
+
if (src.shippingFee) ld.returnShippingFeesAmount = {
|
|
12
|
+
"@type": "MonetaryAmount",
|
|
13
|
+
value: src.shippingFee.amount,
|
|
14
|
+
currency: src.shippingFee.currency
|
|
15
|
+
};
|
|
16
|
+
if (src.restockingFeePercent) ld.restockingFee = src.restockingFeePercent;
|
|
17
|
+
if (src.url) ld.merchantReturnLink = src.url;
|
|
18
|
+
return ld;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { buildReturnPolicyLd };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { JsonLdMerchantReturnPolicy } from "./merchant-return-policy-ld.js";
|
|
2
|
+
import { OrganizationSchemaSource } from "@shop-on/theme-runtime/template-types";
|
|
3
|
+
//#region src/organization-json-ld.d.ts
|
|
4
|
+
export interface OrganizationJsonLdProps {
|
|
5
|
+
data: OrganizationSchemaSource;
|
|
6
|
+
}
|
|
7
|
+
interface JsonLdOrganization {
|
|
8
|
+
"@context": "https://schema.org";
|
|
9
|
+
"@type": "Organization";
|
|
10
|
+
name: string;
|
|
11
|
+
url: string;
|
|
12
|
+
logo?: string;
|
|
13
|
+
hasMerchantReturnPolicy?: JsonLdMerchantReturnPolicy;
|
|
14
|
+
}
|
|
15
|
+
/** The JSON-LD object, before serialization. Exported for tests. */
|
|
16
|
+
export declare function buildOrganizationLd(data: OrganizationSchemaSource): JsonLdOrganization;
|
|
17
|
+
export declare function OrganizationJsonLd({ data }: OrganizationJsonLdProps): import("react").JSX.Element;
|
|
18
|
+
//#endregion
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { buildReturnPolicyLd } from "./merchant-return-policy-ld.js";
|
|
2
|
+
import { escapeForScriptTag } from "@shop-on/theme-runtime/json-ld-escape";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/organization-json-ld.tsx
|
|
5
|
+
/** The JSON-LD object, before serialization. Exported for tests. */
|
|
6
|
+
function buildOrganizationLd(data) {
|
|
7
|
+
const ld = {
|
|
8
|
+
"@context": "https://schema.org",
|
|
9
|
+
"@type": "Organization",
|
|
10
|
+
name: data.name,
|
|
11
|
+
url: data.url
|
|
12
|
+
};
|
|
13
|
+
if (data.logo) ld.logo = data.logo;
|
|
14
|
+
if (data.returnPolicy) ld.hasMerchantReturnPolicy = buildReturnPolicyLd(data.returnPolicy);
|
|
15
|
+
return ld;
|
|
16
|
+
}
|
|
17
|
+
function OrganizationJsonLd({ data }) {
|
|
18
|
+
const json = escapeForScriptTag(JSON.stringify(buildOrganizationLd(data)));
|
|
19
|
+
return /* @__PURE__ */ jsx("script", {
|
|
20
|
+
type: "application/ld+json",
|
|
21
|
+
dangerouslySetInnerHTML: { __html: json }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { OrganizationJsonLd, buildOrganizationLd };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { JsonLdMerchantReturnPolicy } from "./merchant-return-policy-ld.js";
|
|
1
2
|
import { ProductSchemaSource } from "@shop-on/theme-runtime/template-types";
|
|
2
3
|
//#region src/product-json-ld.d.ts
|
|
3
4
|
export interface ProductJsonLdProps {
|
|
@@ -9,6 +10,7 @@ interface JsonLdOffer {
|
|
|
9
10
|
priceCurrency: string;
|
|
10
11
|
availability: string;
|
|
11
12
|
url?: string;
|
|
13
|
+
hasMerchantReturnPolicy?: JsonLdMerchantReturnPolicy;
|
|
12
14
|
}
|
|
13
15
|
interface JsonLdAggregateOffer {
|
|
14
16
|
"@type": "AggregateOffer";
|
|
@@ -18,6 +20,7 @@ interface JsonLdAggregateOffer {
|
|
|
18
20
|
priceCurrency: string;
|
|
19
21
|
availability: string;
|
|
20
22
|
url?: string;
|
|
23
|
+
hasMerchantReturnPolicy?: JsonLdMerchantReturnPolicy;
|
|
21
24
|
}
|
|
22
25
|
interface JsonLdProduct {
|
|
23
26
|
"@context": "https://schema.org";
|
|
@@ -26,6 +29,7 @@ interface JsonLdProduct {
|
|
|
26
29
|
description: string;
|
|
27
30
|
image?: string[];
|
|
28
31
|
sku?: string;
|
|
32
|
+
gtin?: string;
|
|
29
33
|
url?: string;
|
|
30
34
|
brand?: {
|
|
31
35
|
"@type": "Brand";
|
package/dist/product-json-ld.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { buildReturnPolicyLd } from "./merchant-return-policy-ld.js";
|
|
1
2
|
import { escapeForScriptTag } from "@shop-on/theme-runtime/json-ld-escape";
|
|
2
3
|
import { jsx } from "react/jsx-runtime";
|
|
3
4
|
//#region src/product-json-ld.tsx
|
|
@@ -18,6 +19,7 @@ function buildProductLd(data) {
|
|
|
18
19
|
availability
|
|
19
20
|
};
|
|
20
21
|
if (data.url) offers.url = data.url;
|
|
22
|
+
if (data.returnPolicy) offers.hasMerchantReturnPolicy = buildReturnPolicyLd(data.returnPolicy);
|
|
21
23
|
const ld = {
|
|
22
24
|
"@context": "https://schema.org",
|
|
23
25
|
"@type": "Product",
|
|
@@ -27,6 +29,7 @@ function buildProductLd(data) {
|
|
|
27
29
|
};
|
|
28
30
|
if (data.images.length) ld.image = data.images;
|
|
29
31
|
if (data.sku) ld.sku = data.sku;
|
|
32
|
+
if (data.gtin) ld.gtin = data.gtin;
|
|
30
33
|
if (data.url) ld.url = data.url;
|
|
31
34
|
if (data.vendor) ld.brand = {
|
|
32
35
|
"@type": "Brand",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shop-on/theme-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"license": "SEE LICENSE IN dist/LICENSE.md",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"./font-stylesheet": "./dist/font-stylesheet.js",
|
|
20
20
|
"./hreflang-links": "./dist/hreflang-links.js",
|
|
21
21
|
"./link-utils": "./dist/link-utils.js",
|
|
22
|
+
"./organization-json-ld": "./dist/organization-json-ld.js",
|
|
22
23
|
"./preview-guard": "./dist/preview-guard.js",
|
|
23
24
|
"./preview-search-middleware": "./dist/preview-search-middleware.js",
|
|
24
25
|
"./product-json-ld": "./dist/product-json-ld.js",
|
|
@@ -33,8 +34,8 @@
|
|
|
33
34
|
"./package.json": "./package.json"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@shop-on/theme-contract": "0.
|
|
37
|
-
"@shop-on/theme-runtime": "0.
|
|
37
|
+
"@shop-on/theme-contract": "0.7.0",
|
|
38
|
+
"@shop-on/theme-runtime": "0.7.0"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@tanstack/react-router": "1.170.45",
|