@treely/strapi-slices 7.10.0 → 7.12.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/components/SEOTags/SEOTags.d.ts +10 -0
- package/dist/models/PageMetadata.d.ts +1 -0
- package/dist/models/strapi/StrapiMetadata.d.ts +1 -0
- package/dist/strapi-slices.cjs.development.js +134 -23
- package/dist/strapi-slices.cjs.development.js.map +1 -1
- package/dist/strapi-slices.cjs.production.min.js +1 -1
- package/dist/strapi-slices.cjs.production.min.js.map +1 -1
- package/dist/strapi-slices.esm.js +134 -23
- package/dist/strapi-slices.esm.js.map +1 -1
- package/package.json +2 -1
- package/src/components/SEOTags/SEOTags.tsx +175 -0
- package/src/models/PageMetadata.ts +1 -0
- package/src/models/strapi/StrapiMetadata.ts +1 -0
- package/src/test/strapiMocks/strapiMetadata.ts +1 -0
- package/src/utils/mergeGlobalAndStrapiBlogPostData.test.ts +81 -0
- package/src/utils/mergeGlobalAndStrapiBlogPostData.ts +6 -0
- package/src/utils/mergeGlobalAndStrapiCustomerStoryData.test.ts +78 -0
- package/src/utils/mergeGlobalAndStrapiCustomerStoryData.ts +6 -0
- package/src/utils/mergeGlobalAndStrapiPageData.test.ts +84 -0
- package/src/utils/mergeGlobalAndStrapiPageData.ts +6 -0
- package/src/utils/mergeGlobalAndStrapiProjectData.test.ts +81 -0
- package/src/utils/mergeGlobalAndStrapiProjectData.ts +6 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { Article, BlogPosting, Brand, BreadcrumbList, Event, FAQPage, HowTo, LocalBusiness, Offer, Organization, Person, Product, Service, WebPage, WithContext } from 'schema-dts';
|
|
3
|
+
type SupportedSchemaType = Article | BlogPosting | Brand | BreadcrumbList | Event | FAQPage | HowTo | LocalBusiness | Offer | Organization | Person | Product | Service | WebPage;
|
|
2
4
|
interface SEOTagsProps {
|
|
3
5
|
title: string;
|
|
4
6
|
description: string;
|
|
@@ -9,6 +11,14 @@ interface SEOTagsProps {
|
|
|
9
11
|
metaTitleSuffix?: string;
|
|
10
12
|
favicon?: string;
|
|
11
13
|
domain?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Structured data for SEO purposes, following the schema.org standard.
|
|
16
|
+
* This can be a single schema object or an array of schema objects.
|
|
17
|
+
* Each object must include an `@context` property set to "https://schema.org"
|
|
18
|
+
* and an `@type` property indicating the type of schema (e.g., Article, Product).
|
|
19
|
+
* The schema falls back to the default schema if it is invalid.
|
|
20
|
+
*/
|
|
21
|
+
schemaMarkup?: WithContext<SupportedSchemaType> | WithContext<SupportedSchemaType>[];
|
|
12
22
|
}
|
|
13
23
|
export declare const SEOTags: React.FC<SEOTagsProps>;
|
|
14
24
|
export {};
|
|
@@ -707,8 +707,9 @@ var SLICES_WITH_CUSTOMER_STORIES = ['sections.customer-stories'];
|
|
|
707
707
|
var SLICES_WITH_PROJECTS = ['sections.projects-grid', 'sections.projects-map', 'sections.project-facts', 'sections.text-with-card'];
|
|
708
708
|
|
|
709
709
|
var mergeGlobalAndStrapiBlogPostData = function mergeGlobalAndStrapiBlogPostData(context, global, post, blog, projects) {
|
|
710
|
-
var _post$attributes$meta, _post$attributes$meta2, _post$attributes$meta3, _global$attributes$me,
|
|
710
|
+
var _post$attributes$meta, _post$attributes$meta2, _post$attributes$meta3, _global$attributes$me, _ref, _post$attributes$meta4, _post$attributes$meta5, _global$attributes$me2, _post$attributes, _post$attributes$meta6, _post$attributes$meta7, _post$attributes$meta8, _post$attributes$meta9, _ref2, _post$attributes$meta10, _post$attributes$meta11, _global$attributes$me3;
|
|
711
711
|
var metaShareImageUrl = (_post$attributes$meta = post.attributes.metadata) != null && _post$attributes$meta.shareImage ? strapiMediaUrl((_post$attributes$meta2 = (_post$attributes$meta3 = post.attributes.metadata) == null ? void 0 : _post$attributes$meta3.shareImage.media) != null ? _post$attributes$meta2 : (_global$attributes$me = global.attributes.metadata.shareImage) == null ? void 0 : _global$attributes$me.media, 'large') : DEFAULT_SHARE_IMAGE;
|
|
712
|
+
var schemaMarkupTypes = (_ref = (_post$attributes$meta4 = (_post$attributes$meta5 = post.attributes.metadata) == null ? void 0 : _post$attributes$meta5.schemaMarkupTypes) != null ? _post$attributes$meta4 : (_global$attributes$me2 = global.attributes.metadata) == null ? void 0 : _global$attributes$me2.schemaMarkupTypes) != null ? _ref : [];
|
|
712
713
|
var returnBlog = post.attributes.slices.some(function (slice) {
|
|
713
714
|
return SLICES_WITH_BLOG_POSTS.includes(slice.__component);
|
|
714
715
|
});
|
|
@@ -731,14 +732,15 @@ var mergeGlobalAndStrapiBlogPostData = function mergeGlobalAndStrapiBlogPostData
|
|
|
731
732
|
headerButtons: global.attributes.navbar.buttons || [],
|
|
732
733
|
footerLinks: global.attributes.footer.links || [],
|
|
733
734
|
metadata: {
|
|
734
|
-
title: (_post$attributes$
|
|
735
|
-
description: (_post$attributes$
|
|
735
|
+
title: (_post$attributes$meta6 = (_post$attributes$meta7 = post.attributes.metadata) == null ? void 0 : _post$attributes$meta7.title) != null ? _post$attributes$meta6 : global.attributes.metadata.title,
|
|
736
|
+
description: (_post$attributes$meta8 = (_post$attributes$meta9 = post.attributes.metadata) == null ? void 0 : _post$attributes$meta9.description) != null ? _post$attributes$meta8 : global.attributes.metadata.description,
|
|
736
737
|
shareImage: {
|
|
737
738
|
url: metaShareImageUrl,
|
|
738
|
-
alt: (
|
|
739
|
+
alt: (_ref2 = (_post$attributes$meta10 = (_post$attributes$meta11 = post.attributes.metadata) == null || (_post$attributes$meta11 = _post$attributes$meta11.shareImage) == null ? void 0 : _post$attributes$meta11.alt) != null ? _post$attributes$meta10 : (_global$attributes$me3 = global.attributes.metadata.shareImage) == null ? void 0 : _global$attributes$me3.alt) != null ? _ref2 : DEFAULT_SHARE_ALT
|
|
739
740
|
},
|
|
740
741
|
metaTitleSuffix: global.attributes.metaTitleSuffix,
|
|
741
|
-
favicon: strapiMediaUrl(global.attributes.favicon, 'thumbnail')
|
|
742
|
+
favicon: strapiMediaUrl(global.attributes.favicon, 'thumbnail'),
|
|
743
|
+
schemaMarkupTypes: schemaMarkupTypes
|
|
742
744
|
},
|
|
743
745
|
slices: post == null ? void 0 : post.attributes.slices,
|
|
744
746
|
blogPosts: returnBlog ? blog : [],
|
|
@@ -751,8 +753,9 @@ var mergeGlobalAndStrapiBlogPostData = function mergeGlobalAndStrapiBlogPostData
|
|
|
751
753
|
};
|
|
752
754
|
|
|
753
755
|
var mergeGlobalAndStrapiCustomerStoryData = function mergeGlobalAndStrapiCustomerStoryData(context, global, customerStory, customerStories) {
|
|
754
|
-
var _customerStory$attrib, _customerStory$attrib2, _customerStory$attrib3, _global$attributes$me, _customerStory$attrib4, _customerStory$attrib5, _customerStory$attrib6, _customerStory$attrib7, _customerStory$attrib8,
|
|
756
|
+
var _customerStory$attrib, _customerStory$attrib2, _customerStory$attrib3, _global$attributes$me, _ref, _customerStory$attrib4, _customerStory$attrib5, _global$attributes$me2, _customerStory$attrib6, _customerStory$attrib7, _customerStory$attrib8, _customerStory$attrib9, _customerStory$attrib10, _ref2, _customerStory$attrib11, _customerStory$attrib12, _global$attributes$me3;
|
|
755
757
|
var metaShareImageUrl = (_customerStory$attrib = customerStory.attributes.metadata) != null && _customerStory$attrib.shareImage ? strapiMediaUrl((_customerStory$attrib2 = (_customerStory$attrib3 = customerStory.attributes.metadata) == null ? void 0 : _customerStory$attrib3.shareImage.media) != null ? _customerStory$attrib2 : (_global$attributes$me = global.attributes.metadata.shareImage) == null ? void 0 : _global$attributes$me.media, 'large') : DEFAULT_SHARE_IMAGE;
|
|
758
|
+
var schemaMarkupTypes = (_ref = (_customerStory$attrib4 = (_customerStory$attrib5 = customerStory.attributes.metadata) == null ? void 0 : _customerStory$attrib5.schemaMarkupTypes) != null ? _customerStory$attrib4 : (_global$attributes$me2 = global.attributes.metadata) == null ? void 0 : _global$attributes$me2.schemaMarkupTypes) != null ? _ref : [];
|
|
756
759
|
var returnCustomerStories = customerStory.attributes.slices.some(function (slice) {
|
|
757
760
|
return SLICES_WITH_CUSTOMER_STORIES.includes(slice.__component);
|
|
758
761
|
});
|
|
@@ -760,7 +763,7 @@ var mergeGlobalAndStrapiCustomerStoryData = function mergeGlobalAndStrapiCustome
|
|
|
760
763
|
// Portfolio Projects
|
|
761
764
|
projects: [],
|
|
762
765
|
attributes: _extends({}, customerStory == null ? void 0 : customerStory.attributes, {
|
|
763
|
-
metadata: (customerStory == null || (_customerStory$
|
|
766
|
+
metadata: (customerStory == null || (_customerStory$attrib6 = customerStory.attributes) == null ? void 0 : _customerStory$attrib6.metadata) || global.attributes.metadata
|
|
764
767
|
}),
|
|
765
768
|
// PageProps
|
|
766
769
|
headerType: {
|
|
@@ -771,14 +774,15 @@ var mergeGlobalAndStrapiCustomerStoryData = function mergeGlobalAndStrapiCustome
|
|
|
771
774
|
headerButtons: global.attributes.navbar.buttons || [],
|
|
772
775
|
footerLinks: global.attributes.footer.links || [],
|
|
773
776
|
metadata: {
|
|
774
|
-
title: (_customerStory$
|
|
775
|
-
description: (_customerStory$
|
|
777
|
+
title: (_customerStory$attrib7 = (_customerStory$attrib8 = customerStory.attributes.metadata) == null ? void 0 : _customerStory$attrib8.title) != null ? _customerStory$attrib7 : global.attributes.metadata.title,
|
|
778
|
+
description: (_customerStory$attrib9 = (_customerStory$attrib10 = customerStory.attributes.metadata) == null ? void 0 : _customerStory$attrib10.description) != null ? _customerStory$attrib9 : global.attributes.metadata.description,
|
|
776
779
|
shareImage: {
|
|
777
780
|
url: metaShareImageUrl,
|
|
778
|
-
alt: (
|
|
781
|
+
alt: (_ref2 = (_customerStory$attrib11 = (_customerStory$attrib12 = customerStory.attributes.metadata) == null || (_customerStory$attrib12 = _customerStory$attrib12.shareImage) == null ? void 0 : _customerStory$attrib12.alt) != null ? _customerStory$attrib11 : (_global$attributes$me3 = global.attributes.metadata.shareImage) == null ? void 0 : _global$attributes$me3.alt) != null ? _ref2 : DEFAULT_SHARE_ALT
|
|
779
782
|
},
|
|
780
783
|
metaTitleSuffix: global.attributes.metaTitleSuffix,
|
|
781
|
-
favicon: strapiMediaUrl(global.attributes.favicon, 'thumbnail')
|
|
784
|
+
favicon: strapiMediaUrl(global.attributes.favicon, 'thumbnail'),
|
|
785
|
+
schemaMarkupTypes: schemaMarkupTypes
|
|
782
786
|
},
|
|
783
787
|
slices: customerStory == null ? void 0 : customerStory.attributes.slices,
|
|
784
788
|
customerStories: returnCustomerStories ? customerStories : [],
|
|
@@ -791,8 +795,9 @@ var mergeGlobalAndStrapiCustomerStoryData = function mergeGlobalAndStrapiCustome
|
|
|
791
795
|
};
|
|
792
796
|
|
|
793
797
|
var mergeGlobalAndStrapiPageData = function mergeGlobalAndStrapiPageData(context, global, page, blogPosts, customerStories, projects) {
|
|
794
|
-
var _page$attributes$meta, _page$attributes$meta2, _page$attributes$meta3, _global$attributes$me, _page$attributes$meta4, _page$attributes, _page$attributes$slic, _page$attributes$slic2, _page$attributes$
|
|
798
|
+
var _page$attributes$meta, _page$attributes$meta2, _page$attributes$meta3, _global$attributes$me, _ref, _page$attributes$meta4, _page$attributes$meta5, _global$attributes$me2, _page$attributes$meta6, _page$attributes, _page$attributes$slic, _page$attributes$slic2, _page$attributes$meta7, _page$attributes$meta8, _page$attributes$meta9, _page$attributes$meta10, _ref2, _page$attributes$meta11, _page$attributes$meta12, _global$attributes$me3;
|
|
795
799
|
var metaShareImageUrl = (_page$attributes$meta = page.attributes.metadata) != null && _page$attributes$meta.shareImage ? strapiMediaUrl((_page$attributes$meta2 = (_page$attributes$meta3 = page.attributes.metadata) == null ? void 0 : _page$attributes$meta3.shareImage.media) != null ? _page$attributes$meta2 : (_global$attributes$me = global.attributes.metadata.shareImage) == null ? void 0 : _global$attributes$me.media, 'large') : DEFAULT_SHARE_IMAGE;
|
|
800
|
+
var schemaMarkupTypes = (_ref = (_page$attributes$meta4 = (_page$attributes$meta5 = page.attributes.metadata) == null ? void 0 : _page$attributes$meta5.schemaMarkupTypes) != null ? _page$attributes$meta4 : (_global$attributes$me2 = global.attributes.metadata) == null ? void 0 : _global$attributes$me2.schemaMarkupTypes) != null ? _ref : [];
|
|
796
801
|
var returnBlogPosts = page.attributes.slices.some(function (slice) {
|
|
797
802
|
return SLICES_WITH_BLOG_POSTS.includes(slice.__component);
|
|
798
803
|
});
|
|
@@ -807,7 +812,7 @@ var mergeGlobalAndStrapiPageData = function mergeGlobalAndStrapiPageData(context
|
|
|
807
812
|
projects: returnProjects ? projects : [],
|
|
808
813
|
// StrapiPage
|
|
809
814
|
attributes: _extends({}, page == null ? void 0 : page.attributes, {
|
|
810
|
-
metadata: (_page$attributes$
|
|
815
|
+
metadata: (_page$attributes$meta6 = page == null || (_page$attributes = page.attributes) == null ? void 0 : _page$attributes.metadata) != null ? _page$attributes$meta6 : global.attributes.metadata
|
|
811
816
|
}),
|
|
812
817
|
// PageProps
|
|
813
818
|
headerType: {
|
|
@@ -818,14 +823,15 @@ var mergeGlobalAndStrapiPageData = function mergeGlobalAndStrapiPageData(context
|
|
|
818
823
|
headerButtons: global.attributes.navbar.buttons || [],
|
|
819
824
|
footerLinks: global.attributes.footer.links || [],
|
|
820
825
|
metadata: {
|
|
821
|
-
title: (_page$attributes$
|
|
822
|
-
description: (_page$attributes$
|
|
826
|
+
title: (_page$attributes$meta7 = (_page$attributes$meta8 = page.attributes.metadata) == null ? void 0 : _page$attributes$meta8.title) != null ? _page$attributes$meta7 : global.attributes.metadata.title,
|
|
827
|
+
description: (_page$attributes$meta9 = (_page$attributes$meta10 = page.attributes.metadata) == null ? void 0 : _page$attributes$meta10.description) != null ? _page$attributes$meta9 : global.attributes.metadata.description,
|
|
823
828
|
shareImage: {
|
|
824
829
|
url: metaShareImageUrl,
|
|
825
|
-
alt: (
|
|
830
|
+
alt: (_ref2 = (_page$attributes$meta11 = (_page$attributes$meta12 = page.attributes.metadata) == null || (_page$attributes$meta12 = _page$attributes$meta12.shareImage) == null ? void 0 : _page$attributes$meta12.alt) != null ? _page$attributes$meta11 : (_global$attributes$me3 = global.attributes.metadata.shareImage) == null ? void 0 : _global$attributes$me3.alt) != null ? _ref2 : DEFAULT_SHARE_ALT
|
|
826
831
|
},
|
|
827
832
|
metaTitleSuffix: global.attributes.metaTitleSuffix,
|
|
828
|
-
favicon: strapiMediaUrl(global.attributes.favicon, 'thumbnail')
|
|
833
|
+
favicon: strapiMediaUrl(global.attributes.favicon, 'thumbnail'),
|
|
834
|
+
schemaMarkupTypes: schemaMarkupTypes
|
|
829
835
|
},
|
|
830
836
|
slices: page == null ? void 0 : page.attributes.slices,
|
|
831
837
|
blogPosts: returnBlogPosts ? blogPosts : [],
|
|
@@ -838,8 +844,9 @@ var mergeGlobalAndStrapiPageData = function mergeGlobalAndStrapiPageData(context
|
|
|
838
844
|
};
|
|
839
845
|
|
|
840
846
|
var mergeGlobalAndStrapiProject = function mergeGlobalAndStrapiProject(context, global, project, blogPosts, projects) {
|
|
841
|
-
var _project$attributes$m, _project$attributes$m2, _project$attributes$m3, _global$attributes$me, _project$attributes, _project$attributes$s, _project$attributes$s2, _project$attributes$
|
|
847
|
+
var _project$attributes$m, _project$attributes$m2, _project$attributes$m3, _global$attributes$me, _ref, _project$attributes$m4, _project$attributes$m5, _global$attributes$me2, _project$attributes, _project$attributes$s, _project$attributes$s2, _project$attributes$m6, _project$attributes$m7, _project$attributes$m8, _project$attributes$m9, _ref2, _project$attributes$m10, _project$attributes$m11, _global$attributes$me3;
|
|
842
848
|
var metaShareImageUrl = (_project$attributes$m = project.attributes.metadata) != null && _project$attributes$m.shareImage ? strapiMediaUrl((_project$attributes$m2 = (_project$attributes$m3 = project.attributes.metadata) == null ? void 0 : _project$attributes$m3.shareImage.media) != null ? _project$attributes$m2 : (_global$attributes$me = global.attributes.metadata.shareImage) == null ? void 0 : _global$attributes$me.media, 'large') : DEFAULT_SHARE_IMAGE;
|
|
849
|
+
var schemaMarkupTypes = (_ref = (_project$attributes$m4 = (_project$attributes$m5 = project.attributes.metadata) == null ? void 0 : _project$attributes$m5.schemaMarkupTypes) != null ? _project$attributes$m4 : (_global$attributes$me2 = global.attributes.metadata) == null ? void 0 : _global$attributes$me2.schemaMarkupTypes) != null ? _ref : [];
|
|
843
850
|
var returnBlogPosts = project.attributes.slices.some(function (slice) {
|
|
844
851
|
return SLICES_WITH_BLOG_POSTS.includes(slice.__component);
|
|
845
852
|
});
|
|
@@ -862,14 +869,15 @@ var mergeGlobalAndStrapiProject = function mergeGlobalAndStrapiProject(context,
|
|
|
862
869
|
headerButtons: global.attributes.navbar.buttons || [],
|
|
863
870
|
footerLinks: global.attributes.footer.links || [],
|
|
864
871
|
metadata: {
|
|
865
|
-
title: (_project$attributes$
|
|
866
|
-
description: (_project$attributes$
|
|
872
|
+
title: (_project$attributes$m6 = (_project$attributes$m7 = project.attributes.metadata) == null ? void 0 : _project$attributes$m7.title) != null ? _project$attributes$m6 : global.attributes.metadata.title,
|
|
873
|
+
description: (_project$attributes$m8 = (_project$attributes$m9 = project.attributes.metadata) == null ? void 0 : _project$attributes$m9.description) != null ? _project$attributes$m8 : global.attributes.metadata.description,
|
|
867
874
|
shareImage: {
|
|
868
875
|
url: metaShareImageUrl,
|
|
869
|
-
alt: (
|
|
876
|
+
alt: (_ref2 = (_project$attributes$m10 = (_project$attributes$m11 = project.attributes.metadata) == null || (_project$attributes$m11 = _project$attributes$m11.shareImage) == null ? void 0 : _project$attributes$m11.alt) != null ? _project$attributes$m10 : (_global$attributes$me3 = global.attributes.metadata.shareImage) == null ? void 0 : _global$attributes$me3.alt) != null ? _ref2 : DEFAULT_SHARE_ALT
|
|
870
877
|
},
|
|
871
878
|
metaTitleSuffix: global.attributes.metaTitleSuffix,
|
|
872
|
-
favicon: strapiMediaUrl(global.attributes.favicon, 'thumbnail')
|
|
879
|
+
favicon: strapiMediaUrl(global.attributes.favicon, 'thumbnail'),
|
|
880
|
+
schemaMarkupTypes: schemaMarkupTypes
|
|
873
881
|
},
|
|
874
882
|
slices: project.attributes.slices,
|
|
875
883
|
blogPosts: returnBlogPosts ? blogPosts : [],
|
|
@@ -903,6 +911,86 @@ var PreviewAlert = function PreviewAlert() {
|
|
|
903
911
|
}));
|
|
904
912
|
};
|
|
905
913
|
|
|
914
|
+
// Helper function to convert SchemaValue to string
|
|
915
|
+
var getTextValue = function getTextValue(value) {
|
|
916
|
+
if (typeof value === 'string') return value;
|
|
917
|
+
if (typeof value === 'object' && value !== null && 'text' in value) {
|
|
918
|
+
return value.text;
|
|
919
|
+
}
|
|
920
|
+
return '';
|
|
921
|
+
};
|
|
922
|
+
// Helper function to safely access properties from a schema
|
|
923
|
+
var getSchemaProperty = function getSchemaProperty(schema, property) {
|
|
924
|
+
return getTextValue(schema[property]) || '';
|
|
925
|
+
};
|
|
926
|
+
// Helper function to get a unique identifier from a schema
|
|
927
|
+
var getSchemaIdentifier = function getSchemaIdentifier(schema) {
|
|
928
|
+
var _offer$price;
|
|
929
|
+
var type = schema['@type'];
|
|
930
|
+
switch (type) {
|
|
931
|
+
case 'Organization':
|
|
932
|
+
return getSchemaProperty(schema, 'name') || 'default';
|
|
933
|
+
case 'Article':
|
|
934
|
+
case 'BlogPosting':
|
|
935
|
+
return getSchemaProperty(schema, 'headline') || 'untitled-article';
|
|
936
|
+
case 'Product':
|
|
937
|
+
return getSchemaProperty(schema, 'name') || 'untitled-product';
|
|
938
|
+
case 'Person':
|
|
939
|
+
return getSchemaProperty(schema, 'name') || 'unnamed-person';
|
|
940
|
+
case 'Event':
|
|
941
|
+
return getSchemaProperty(schema, 'name') || 'untitled-event';
|
|
942
|
+
case 'LocalBusiness':
|
|
943
|
+
return getSchemaProperty(schema, 'name') || 'unnamed-business';
|
|
944
|
+
case 'Service':
|
|
945
|
+
return getSchemaProperty(schema, 'name') || 'unnamed-service';
|
|
946
|
+
case 'Brand':
|
|
947
|
+
return getSchemaProperty(schema, 'name') || 'unnamed-brand';
|
|
948
|
+
case 'FAQPage':
|
|
949
|
+
return 'faq-page';
|
|
950
|
+
case 'HowTo':
|
|
951
|
+
return getSchemaProperty(schema, 'name') || 'untitled-howto';
|
|
952
|
+
case 'BreadcrumbList':
|
|
953
|
+
return 'breadcrumbs';
|
|
954
|
+
case 'Offer':
|
|
955
|
+
var offer = schema;
|
|
956
|
+
return "offer-" + ((_offer$price = offer.price) != null ? _offer$price : 'unknown-price');
|
|
957
|
+
case 'WebPage':
|
|
958
|
+
return getSchemaProperty(schema, 'name') || 'untitled-page';
|
|
959
|
+
default:
|
|
960
|
+
return 'unknown-schema';
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
var validateSchema = function validateSchema(schema) {
|
|
964
|
+
if (Array.isArray(schema)) {
|
|
965
|
+
return schema.every(function (item) {
|
|
966
|
+
return item['@context'] === 'https://schema.org' && '@type' in item;
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
return schema['@context'] === 'https://schema.org' && '@type' in schema;
|
|
970
|
+
};
|
|
971
|
+
var DEFAULT_SCHEMA = {
|
|
972
|
+
'@context': 'https://schema.org',
|
|
973
|
+
'@type': 'Organization',
|
|
974
|
+
name: 'Tree.ly',
|
|
975
|
+
url: 'https://tree.ly',
|
|
976
|
+
logo: 'https://cdn.tree.ly/logo.png',
|
|
977
|
+
address: {
|
|
978
|
+
'@type': 'PostalAddress',
|
|
979
|
+
streetAddress: 'Littengasse 2b/c',
|
|
980
|
+
addressLocality: 'Dornbirn',
|
|
981
|
+
postalCode: '6850',
|
|
982
|
+
addressRegion: 'Vorarlberg',
|
|
983
|
+
addressCountry: 'AT'
|
|
984
|
+
},
|
|
985
|
+
contactPoint: {
|
|
986
|
+
'@type': 'ContactPoint',
|
|
987
|
+
telephone: '+43-5572-432015',
|
|
988
|
+
contactType: 'Customer Service',
|
|
989
|
+
areaServed: 'AT',
|
|
990
|
+
availableLanguage: ['English', 'German']
|
|
991
|
+
},
|
|
992
|
+
sameAs: ['https://www.linkedin.com/company/tree-ly', 'https://www.facebook.com/treely', 'https://www.instagram.com/treely']
|
|
993
|
+
};
|
|
906
994
|
var SEOTags = function SEOTags(_ref) {
|
|
907
995
|
var _shareImage$url, _shareImage$alt;
|
|
908
996
|
var title = _ref.title,
|
|
@@ -913,9 +1001,24 @@ var SEOTags = function SEOTags(_ref) {
|
|
|
913
1001
|
_ref$favicon = _ref.favicon,
|
|
914
1002
|
favicon = _ref$favicon === void 0 ? 'https://cdn.tree.ly/favicon.ico' : _ref$favicon,
|
|
915
1003
|
_ref$domain = _ref.domain,
|
|
916
|
-
domain = _ref$domain === void 0 ? 'tree.ly' : _ref$domain
|
|
1004
|
+
domain = _ref$domain === void 0 ? 'tree.ly' : _ref$domain,
|
|
1005
|
+
schemaMarkup = _ref.schemaMarkup;
|
|
917
1006
|
var shareImageUrl = (_shareImage$url = shareImage == null ? void 0 : shareImage.url) != null ? _shareImage$url : DEFAULT_SHARE_IMAGE;
|
|
918
1007
|
var shareImageAlt = (_shareImage$alt = shareImage == null ? void 0 : shareImage.alt) != null ? _shareImage$alt : DEFAULT_SHARE_ALT;
|
|
1008
|
+
var schemas = schemaMarkup || DEFAULT_SCHEMA;
|
|
1009
|
+
var isValidSchema = validateSchema(schemas);
|
|
1010
|
+
if (schemaMarkup && !isValidSchema) {
|
|
1011
|
+
console.warn('Invalid schema markup provided to SEOTags component. Falling back to default schema.', schemaMarkup);
|
|
1012
|
+
schemas = DEFAULT_SCHEMA;
|
|
1013
|
+
isValidSchema = true;
|
|
1014
|
+
}
|
|
1015
|
+
var schemaArray = Array.isArray(schemas) ? schemas : [schemas];
|
|
1016
|
+
var getSchemaKey = function getSchemaKey(schema, index) {
|
|
1017
|
+
var type = schema['@type'];
|
|
1018
|
+
var identifier = getSchemaIdentifier(schema);
|
|
1019
|
+
// Add index to ensure uniqueness, especially for fallback identifiers
|
|
1020
|
+
return type + "-" + identifier + "-" + index;
|
|
1021
|
+
};
|
|
919
1022
|
return React__default.default.createElement(Head__default.default, null, React__default.default.createElement("title", null, title + " - " + metaTitleSuffix), React__default.default.createElement("meta", {
|
|
920
1023
|
name: "description",
|
|
921
1024
|
content: description
|
|
@@ -961,6 +1064,14 @@ var SEOTags = function SEOTags(_ref) {
|
|
|
961
1064
|
}), React__default.default.createElement("meta", {
|
|
962
1065
|
name: "twitter:image:alt",
|
|
963
1066
|
content: shareImageAlt
|
|
1067
|
+
}), isValidSchema && schemaArray.map(function (schema, index) {
|
|
1068
|
+
return React__default.default.createElement("script", {
|
|
1069
|
+
key: getSchemaKey(schema, index),
|
|
1070
|
+
type: "application/ld+json",
|
|
1071
|
+
dangerouslySetInnerHTML: {
|
|
1072
|
+
__html: JSON.stringify(schema)
|
|
1073
|
+
}
|
|
1074
|
+
});
|
|
964
1075
|
}));
|
|
965
1076
|
};
|
|
966
1077
|
|