gatsby-core-theme 4.0.0 → 5.0.2
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/CHANGELOG.md +68 -0
- package/package.json +1 -1
- package/src/components/atoms/author-box/index.js +2 -1
- package/src/components/atoms/spotlights/index.js +6 -3
- package/src/components/molecules/carousel/default-slide/index.js +3 -1
- package/src/components/molecules/slider/index.js +6 -0
- package/src/components/organisms/anchor/index.js +14 -11
- package/src/components/organisms/carousel/index.js +16 -3
- package/src/helpers/getters.js +14 -0
- package/src/helpers/schema.js +13 -5
- package/src/helpers/schema.test.js +13 -10
- package/src/hooks/lazy-image/index.js +36 -36
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,71 @@
|
|
|
1
|
+
## [5.0.2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v5.0.1...v5.0.2) (2022-03-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* disabled lighthouse ([cb06eaf](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/cb06eaf1cd70de80cfc4eabc17bea8effde1d4d3))
|
|
7
|
+
* tracker link default to main if toplist custom tracker name not exist ([8f9b25f](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/8f9b25f284d779f57e53edb05533feec78d71207))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
* Merge branch 'master' of git.ilcd.rocks:team-floyd/themes/gatsby-themes ([591ffa4](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/591ffa4a83cfc72d3dd11bb9b453b0296fe6d792))
|
|
11
|
+
|
|
12
|
+
## [5.0.1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v5.0.0...v5.0.1) (2022-03-02)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* google bot images ([53fc90c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/53fc90c24cc7bacc9d5911fb05c29dae611fbc1f))
|
|
18
|
+
* lazy image tests ([ef63ea8](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/ef63ea88cd2ff7b3dac335afd30e75e872cdff61))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
* Merge branch 'tm-2743-googlebot-images' into 'master' ([2156666](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/21566661cd703480bb5e58bba9b2b6e1ecb49121))
|
|
22
|
+
|
|
23
|
+
# [5.0.0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v4.0.0...v5.0.0) (2022-03-01)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* add slidetitle alt to images ([669ebdf](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/669ebdf4f352558569ac5d122f1d790ae5f1a4e1))
|
|
29
|
+
* add src name as a title ([71afdbf](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/71afdbf9a6c2de26022978aecc9313f1132981fa))
|
|
30
|
+
* add src name as a title ([4e4cae2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/4e4cae288a80364c2d824673c08abb6cd7ea2738))
|
|
31
|
+
* added no script tag for all images even when using native lazy loading ([513dd8b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/513dd8b8501fbb0ea0a7e4210503826da942828a))
|
|
32
|
+
* author box alt tag ([7a1a76c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/7a1a76c8ad1cbde35952e0eb12bcbbcce030cb47))
|
|
33
|
+
* fix html for anchor ([11518ca](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/11518caa9246edb373e2a6b590c2e6d371426d7e))
|
|
34
|
+
* schema fixes ([95f3adf](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/95f3adf1ca366ed01184d5b93bcb7c721bf38177))
|
|
35
|
+
* schema fixes ([c684519](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c6845195c7b37f02cf09d795db27ccfd31f9c5bf))
|
|
36
|
+
* set interface of cssstyledeclaration on each render ([7c0060a](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/7c0060af75a13409a36ce67243f9afd92642a7f4))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Code Refactoring
|
|
40
|
+
|
|
41
|
+
* added image cdn urls ([1eeba30](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/1eeba30c042b85ff0a814944484f33ad814dcb92))
|
|
42
|
+
* changes to image cdn url ([052df45](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/052df45ad2eb9e38c9b147b3477cd6b3f82ec505))
|
|
43
|
+
* changes to image cdn url ([c3eb17e](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c3eb17e4f71e50aaacaf1eb5845d472ca9f188c2))
|
|
44
|
+
* create fileName getter fnc ([a1dc8ac](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a1dc8acbd40c362e73aafa19eecf7814ba9df17f))
|
|
45
|
+
* remove cross-env ([a12e65b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a12e65b4f7d5fc277103f860dd702195b1bda97c))
|
|
46
|
+
* remove test data ([657abde](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/657abdeef0ad948c64c1120e055db8d0a924106e))
|
|
47
|
+
* remove test data ([04649e6](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/04649e649b2e1a4ca497f61e520bf2b1cc032f4f))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
* Merge branch 'tm-2729-alt-tags' into 'master' ([f2776f2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/f2776f2c31520822848b7b811df38405df26bef5))
|
|
51
|
+
* Merge branch 'tm-2743-noscript-tag' into 'master' ([26bc7d2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/26bc7d296af7175f31eac582d031b3bc7eb5fe6b))
|
|
52
|
+
* Merge branch 'tm-2740-carousel-fix' into 'master' ([a537f2f](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a537f2f41d665e661e1486015f99ceb47d59fbce))
|
|
53
|
+
* Merge branch 'test-schema' into 'master' ([29641f7](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/29641f7e2142ff0fb0a4b76f4201e758cf150aed))
|
|
54
|
+
* Merge branch 'tm-2706-custom-demo-deployment' into 'master' ([7383e0d](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/7383e0daddf51de0901dd4c441e6016c61d60224))
|
|
55
|
+
* Merge branch 'master' into tm-2706-custom-demo-deployment ([8a3d1ed](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/8a3d1ed442250caa2be532138dba244b95cb1378))
|
|
56
|
+
* Merge branch 'tm-2721-fixhtml-anchor' into 'master' ([39a160c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/39a160cb88d7a352427e99a90fb4dc6655e9a877))
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Tests
|
|
60
|
+
|
|
61
|
+
* schema changes ([c59116f](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c59116f5d2122c97b2dd18e62b85358685cca277))
|
|
62
|
+
* temp test ([fb1bb3f](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/fb1bb3f44d07e2e8d96a8bdf4008e9d58c16e233))
|
|
63
|
+
* temp test ([11a0b99](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/11a0b99c235cabb9f11831c8647f2ba0aa0c7f31))
|
|
64
|
+
* temp test ([f81d84a](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/f81d84a3114d7ff4159a482e2db23dd8872c70ab))
|
|
65
|
+
* temp test ([03ab914](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/03ab914910aeb4180448f66f5abd09a92af087a5))
|
|
66
|
+
* temp test ([ec052c0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/ec052c0dc395b8428e214db526c0000dcc8b2b68))
|
|
67
|
+
* temp test ([b2227b0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/b2227b0170703795fce93e6d4ecfe6d1b8dd4446))
|
|
68
|
+
|
|
1
69
|
# [4.0.0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v3.0.0...v4.0.0) (2022-02-21)
|
|
2
70
|
|
|
3
71
|
|
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ export default function AuthorBox({ author }) {
|
|
|
16
16
|
{ id: 'li', link: author.linkedin_profile, icon: <FaLinkedin /> },
|
|
17
17
|
{ id: 'tw', link: author.twitter_profile, icon: <FaTwitter /> },
|
|
18
18
|
];
|
|
19
|
+
|
|
19
20
|
return (
|
|
20
21
|
<div className={styles.container}>
|
|
21
22
|
<div className={styles.innerContainer}>
|
|
@@ -23,7 +24,7 @@ export default function AuthorBox({ author }) {
|
|
|
23
24
|
{author.image_object && (
|
|
24
25
|
<LazyImage
|
|
25
26
|
src={imagePrettyUrl(author.image_object.filename)}
|
|
26
|
-
alt={author.image_alt}
|
|
27
|
+
alt={author.image_alt || author.name}
|
|
27
28
|
width={author.image_object?.width}
|
|
28
29
|
height={author.image_object?.height}
|
|
29
30
|
/>
|
|
@@ -7,7 +7,7 @@ import { GrFormNextLink } from 'react-icons/gr';
|
|
|
7
7
|
import Button from '~atoms/button';
|
|
8
8
|
import LazyImage from '~hooks/lazy-image';
|
|
9
9
|
import keygen from '~helpers/keygen';
|
|
10
|
-
import { imagePrettyUrl } from '~helpers/getters';
|
|
10
|
+
import { imagePrettyUrl, getImageFilename } from '~helpers/getters';
|
|
11
11
|
import Link from '~hooks/link';
|
|
12
12
|
import styles from './spotlights.module.scss';
|
|
13
13
|
|
|
@@ -16,13 +16,16 @@ const Spotlights = ({ module, themeStyles = {} }) => {
|
|
|
16
16
|
|
|
17
17
|
const content = (item) => {
|
|
18
18
|
const img = mode === 'icon' ? item.icon : item.image;
|
|
19
|
+
const imageSrc = imagePrettyUrl(img);
|
|
20
|
+
const fileName = getImageFilename(imageSrc);
|
|
21
|
+
|
|
19
22
|
return (
|
|
20
23
|
<>
|
|
21
24
|
<LazyImage
|
|
22
25
|
width={100}
|
|
23
26
|
height={50}
|
|
24
|
-
alt={item.label || item?.link_text}
|
|
25
|
-
src={
|
|
27
|
+
alt={item.label || item?.link_text || fileName}
|
|
28
|
+
src={imageSrc}
|
|
26
29
|
/>
|
|
27
30
|
<label>{item.label}</label>
|
|
28
31
|
{item.subtitle && <span>{item.subtitle}</span>}
|
|
@@ -13,6 +13,7 @@ const Slide = ({
|
|
|
13
13
|
primaryBtnText = '',
|
|
14
14
|
secondaryBtnText = '',
|
|
15
15
|
imageSizes = { width: null, height: 930 },
|
|
16
|
+
slideTitle = '',
|
|
16
17
|
}) => {
|
|
17
18
|
return (
|
|
18
19
|
<>
|
|
@@ -21,7 +22,7 @@ const Slide = ({
|
|
|
21
22
|
<LazyImage
|
|
22
23
|
className={styles.image}
|
|
23
24
|
src={imagePrettyUrl(item.image, imageSizes.width, imageSizes.height)}
|
|
24
|
-
alt={item.title}
|
|
25
|
+
alt={item.title || slideTitle}
|
|
25
26
|
/>
|
|
26
27
|
)}
|
|
27
28
|
{item.content && <p className={styles.content}>{item.content}</p>}
|
|
@@ -62,6 +63,7 @@ Slide.propTypes = {
|
|
|
62
63
|
primaryBtnText: PropTypes.string,
|
|
63
64
|
secondaryBtnText: PropTypes.string,
|
|
64
65
|
imageSizes: PropTypes.shape({ width: PropTypes.any, height: PropTypes.any }),
|
|
66
|
+
slideTitle: PropTypes.string,
|
|
65
67
|
};
|
|
66
68
|
|
|
67
69
|
export default Slide;
|
|
@@ -132,6 +132,12 @@ function Slider({
|
|
|
132
132
|
// Keep slider node reference for multiple carousels in an instance
|
|
133
133
|
const sliderContentNode = sliderContentRef.current;
|
|
134
134
|
|
|
135
|
+
sliderContentNode.style.setProperty('width', style.width);
|
|
136
|
+
sliderContentNode.style.setProperty('transition', style.transition);
|
|
137
|
+
sliderContentNode.style.setProperty('transform', style.transform);
|
|
138
|
+
sliderContentNode.style.setProperty('grid-template-columns', style.gridTemplateColumns);
|
|
139
|
+
sliderContentNode.style.setProperty('gap', style.gridGap);
|
|
140
|
+
|
|
135
141
|
const mousedown = (e) => {
|
|
136
142
|
sliderIsActive.current = true;
|
|
137
143
|
swipeStart(e, updateOnSwipe);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react/no-array-index-key */
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
|
|
@@ -22,18 +23,20 @@ function Anchor({ module: { items }, headerOffset = 80 }) {
|
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
return (
|
|
25
|
-
<
|
|
26
|
-
{items.map((anchor) => (
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
<ul className={styles.anchor}>
|
|
27
|
+
{items.map((anchor, index) => (
|
|
28
|
+
<li key={index}>
|
|
29
|
+
<a
|
|
30
|
+
className={`${styles.link} anchor-carousel-gtm anchor-menu-gtm`}
|
|
31
|
+
key={keygen()}
|
|
32
|
+
onClick={handleClick}
|
|
33
|
+
href={`#${anchor.label && anchorLink(anchor?.label?.toLowerCase().trim())}`}
|
|
34
|
+
>
|
|
35
|
+
{anchor?.label}
|
|
36
|
+
</a>
|
|
37
|
+
</li>
|
|
35
38
|
))}
|
|
36
|
-
</
|
|
39
|
+
</ul>
|
|
37
40
|
);
|
|
38
41
|
}
|
|
39
42
|
|
|
@@ -6,15 +6,25 @@ import Slide from '~molecules/carousel/default-slide';
|
|
|
6
6
|
import keygen from '~helpers/keygen';
|
|
7
7
|
import styles from './carousel.module.scss';
|
|
8
8
|
|
|
9
|
-
const Carousel = ({
|
|
9
|
+
const Carousel = ({
|
|
10
|
+
page = {},
|
|
11
|
+
module = {},
|
|
12
|
+
settings = {},
|
|
13
|
+
CustomSlideComponent,
|
|
14
|
+
gtmClass = '',
|
|
15
|
+
}) => (
|
|
10
16
|
<div className={styles.carouselContainer}>
|
|
11
17
|
<Slider {...settings} gtmClass={gtmClass}>
|
|
12
|
-
{module.items.map((item) => (
|
|
18
|
+
{module.items.map((item, index) => (
|
|
13
19
|
<div key={keygen()} className={styles.carouselItem}>
|
|
14
20
|
{CustomSlideComponent !== undefined ? (
|
|
15
21
|
<CustomSlideComponent item={item} gtmClass={gtmClass} />
|
|
16
22
|
) : (
|
|
17
|
-
<Slide
|
|
23
|
+
<Slide
|
|
24
|
+
slideTitle={`${page.title}-carousel-${index + 1}`}
|
|
25
|
+
item={item}
|
|
26
|
+
gtmClass={gtmClass}
|
|
27
|
+
/>
|
|
18
28
|
)}
|
|
19
29
|
</div>
|
|
20
30
|
))}
|
|
@@ -23,6 +33,9 @@ const Carousel = ({ module = {}, settings = {}, CustomSlideComponent, gtmClass =
|
|
|
23
33
|
);
|
|
24
34
|
|
|
25
35
|
Carousel.propTypes = {
|
|
36
|
+
page: PropTypes.shape({
|
|
37
|
+
title: PropTypes.string,
|
|
38
|
+
}),
|
|
26
39
|
module: PropTypes.shape({
|
|
27
40
|
items: PropTypes.arrayOf(
|
|
28
41
|
PropTypes.shape({
|
package/src/helpers/getters.js
CHANGED
|
@@ -90,6 +90,15 @@ export function image(filename, width, height, fit = 'cover') {
|
|
|
90
90
|
return `${cloudFrontUrl}/${Buffer.from(imageRequest).toString('base64')}`;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
export function getImageFilename(src) {
|
|
94
|
+
const srcArr = src?.substring(src?.lastIndexOf('/') + 1)?.split('.');
|
|
95
|
+
if (!srcArr.length) {
|
|
96
|
+
return '';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return srcArr[0];
|
|
100
|
+
}
|
|
101
|
+
|
|
93
102
|
export function getImageExtension(filename) {
|
|
94
103
|
return filename && filename.split('.').pop();
|
|
95
104
|
}
|
|
@@ -143,6 +152,11 @@ export function prettyTracker(operator, trackerType = 'main') {
|
|
|
143
152
|
return null;
|
|
144
153
|
}
|
|
145
154
|
|
|
155
|
+
// if tracker is not main, check if the tracker exists, if not use main
|
|
156
|
+
if (trackerType !== 'main' && operator.links[trackerType] === undefined) {
|
|
157
|
+
trackerType = 'main';
|
|
158
|
+
}
|
|
159
|
+
|
|
146
160
|
return generateTrackerLink(operator, trackerType);
|
|
147
161
|
}
|
|
148
162
|
|
package/src/helpers/schema.js
CHANGED
|
@@ -98,10 +98,11 @@ export function generateSchemaObject(schema) {
|
|
|
98
98
|
}, {});
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
export function breadcrumbsSchema(breadcrumbs) {
|
|
101
|
+
export function breadcrumbsSchema(breadcrumbs, path) {
|
|
102
102
|
const schema = {
|
|
103
103
|
'@context': 'https://schema.org',
|
|
104
104
|
'@type': 'BreadcrumbList',
|
|
105
|
+
'@id': `${getUrl(path)}#breadcrumblist`,
|
|
105
106
|
itemListElement: breadcrumbs.map((breadcrumb, index) => ({
|
|
106
107
|
'@type': 'ListItem',
|
|
107
108
|
name: breadcrumb.path,
|
|
@@ -177,6 +178,7 @@ export function organizationSchema(page, pageImage) {
|
|
|
177
178
|
const schema = {
|
|
178
179
|
'@context': 'https://schema.org',
|
|
179
180
|
'@type': 'Organization',
|
|
181
|
+
'@id': `${getUrl(page.path)}#organization`,
|
|
180
182
|
url: process.env.GATSBY_SITE_URL,
|
|
181
183
|
name: page.siteSchema?.site_name,
|
|
182
184
|
logo: pageImage,
|
|
@@ -188,13 +190,14 @@ export function organizationSchema(page, pageImage) {
|
|
|
188
190
|
return JSON.stringify(generateSchemaObject(schema));
|
|
189
191
|
}
|
|
190
192
|
|
|
191
|
-
export function moduleSchemas(modules) {
|
|
192
|
-
const schema = modules.map((module) => {
|
|
193
|
+
export function moduleSchemas(modules, path) {
|
|
194
|
+
const schema = modules.map((module, index) => {
|
|
193
195
|
switch (module.name) {
|
|
194
196
|
case 'faq': {
|
|
195
197
|
const moduleSchema = {
|
|
196
198
|
'@context': 'https://schema.org',
|
|
197
199
|
'@type': 'FAQPage',
|
|
200
|
+
'@id': `${getUrl(path)}#faqpage${index === 0 ? '' : index}`,
|
|
198
201
|
mainEntity: module.items?.map((item) => ({
|
|
199
202
|
'@type': 'Question',
|
|
200
203
|
acceptedAnswer: {
|
|
@@ -243,6 +246,7 @@ export function templateSchemas(page, pageImage) {
|
|
|
243
246
|
const schema = {
|
|
244
247
|
'@context': 'https://schema.org',
|
|
245
248
|
'@type': 'Article',
|
|
249
|
+
'@id': `${getUrl(page.path)}#article`,
|
|
246
250
|
url: getUrl(page.path),
|
|
247
251
|
headline: page.title,
|
|
248
252
|
datePublished: page.created_at,
|
|
@@ -260,6 +264,7 @@ export function templateSchemas(page, pageImage) {
|
|
|
260
264
|
const schema = {
|
|
261
265
|
'@context': 'https://schema.org',
|
|
262
266
|
'@type': 'Review',
|
|
267
|
+
'@id': `${getUrl(page.path)}#review`,
|
|
263
268
|
name: page.relation?.name || '',
|
|
264
269
|
reviewBody: page.extra_fields?.operator_summary || '',
|
|
265
270
|
itemReviewed: {
|
|
@@ -284,6 +289,7 @@ export function templateSchemas(page, pageImage) {
|
|
|
284
289
|
const schema = {
|
|
285
290
|
'@context': 'https://schema.org',
|
|
286
291
|
'@type': 'VideoGame',
|
|
292
|
+
'@id': `${getUrl(page.path)}#videogame`,
|
|
287
293
|
url: getUrl(page.path),
|
|
288
294
|
name: page.relation?.name || '',
|
|
289
295
|
description: page.extra_fields?.game_summary || '',
|
|
@@ -319,12 +325,14 @@ export function schemaGenerator(page = {}, pageImage) {
|
|
|
319
325
|
// Page Schema
|
|
320
326
|
page.seo_json_schema,
|
|
321
327
|
// Breadcrumbs Schema
|
|
322
|
-
page.breadcrumbs?.length ? breadcrumbsSchema(page.breadcrumbs) : null,
|
|
328
|
+
page.breadcrumbs?.length ? breadcrumbsSchema(page.breadcrumbs, page.path) : null,
|
|
323
329
|
// Modules Schemas
|
|
324
330
|
webPageSchema(page, pageImage),
|
|
325
331
|
organizationSchema(page, pageImage),
|
|
326
332
|
templateSchemas(page, pageImage),
|
|
327
|
-
...(page.sections?.main?.modules
|
|
333
|
+
...(page.sections?.main?.modules
|
|
334
|
+
? moduleSchemas(page.sections.main.modules, page.path)
|
|
335
|
+
: [null]),
|
|
328
336
|
];
|
|
329
337
|
|
|
330
338
|
return jsonSchema;
|
|
@@ -175,16 +175,19 @@ describe('Schema Helper', () => {
|
|
|
175
175
|
});
|
|
176
176
|
|
|
177
177
|
test('moduleSchemas(faq)', () => {
|
|
178
|
-
const output = Schema.moduleSchemas(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
178
|
+
const output = Schema.moduleSchemas(
|
|
179
|
+
[
|
|
180
|
+
{
|
|
181
|
+
name: 'faq',
|
|
182
|
+
items: [
|
|
183
|
+
{ answer: 'Answer A', question: 'Question A' },
|
|
184
|
+
{ answer: 'Answer B', question: 'Question B' },
|
|
185
|
+
{ answer: 'Answer C', question: 'Question C' },
|
|
186
|
+
],
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
'/'
|
|
190
|
+
)[0];
|
|
188
191
|
|
|
189
192
|
const json = parseCheckSchema(output);
|
|
190
193
|
expect(json['@type']).toEqual('FAQPage');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
2
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import
|
|
4
|
+
import LazyLoad from 'react-lazyload';
|
|
5
5
|
import { isNativeImageLazyLoadingSupported } from '~helpers/device-detect';
|
|
6
6
|
|
|
7
7
|
export default function LazyImage({
|
|
@@ -15,45 +15,17 @@ export default function LazyImage({
|
|
|
15
15
|
loading = 'lazy',
|
|
16
16
|
}) {
|
|
17
17
|
const [errorImage, setErrorImage] = useState(false);
|
|
18
|
+
const [nonNativeLazyLoaded, setNonNativeLazyLoaded] = useState(false);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
setNonNativeLazyLoaded(!isNativeImageLazyLoadingSupported());
|
|
22
|
+
}, []);
|
|
18
23
|
|
|
19
24
|
if ((defaultImg && !src) || errorImage === true) {
|
|
20
25
|
return defaultImg;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
const LazyLoad = loadable(() => import(`react-lazyload`));
|
|
25
|
-
return (
|
|
26
|
-
<>
|
|
27
|
-
<LazyLoad
|
|
28
|
-
height={height ? `${height}px` : null}
|
|
29
|
-
width={width ? `${width}px` : null}
|
|
30
|
-
placeholder={<span className="lazyload-placeholder" />}
|
|
31
|
-
debounce={0}
|
|
32
|
-
>
|
|
33
|
-
<img
|
|
34
|
-
src={src}
|
|
35
|
-
className={className}
|
|
36
|
-
height={height}
|
|
37
|
-
width={width}
|
|
38
|
-
alt={alt}
|
|
39
|
-
style={style}
|
|
40
|
-
/>
|
|
41
|
-
</LazyLoad>
|
|
42
|
-
<noscript>
|
|
43
|
-
<img
|
|
44
|
-
src={src}
|
|
45
|
-
className={className}
|
|
46
|
-
height={height}
|
|
47
|
-
width={width}
|
|
48
|
-
alt={alt}
|
|
49
|
-
style={style}
|
|
50
|
-
/>
|
|
51
|
-
</noscript>
|
|
52
|
-
</>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return (
|
|
28
|
+
return !nonNativeLazyLoaded ? (
|
|
57
29
|
<img
|
|
58
30
|
src={src}
|
|
59
31
|
loading={loading}
|
|
@@ -64,6 +36,34 @@ export default function LazyImage({
|
|
|
64
36
|
style={style}
|
|
65
37
|
onError={() => setErrorImage(true)}
|
|
66
38
|
/>
|
|
39
|
+
) : (
|
|
40
|
+
<>
|
|
41
|
+
<LazyLoad
|
|
42
|
+
height={height ? `${height}px` : null}
|
|
43
|
+
width={width ? `${width}px` : null}
|
|
44
|
+
placeholder={<span className="lazyload-placeholder" />}
|
|
45
|
+
debounce={0}
|
|
46
|
+
>
|
|
47
|
+
<img
|
|
48
|
+
src={src}
|
|
49
|
+
className={className}
|
|
50
|
+
height={height}
|
|
51
|
+
width={width}
|
|
52
|
+
alt={alt}
|
|
53
|
+
style={style}
|
|
54
|
+
/>
|
|
55
|
+
</LazyLoad>
|
|
56
|
+
<noscript>
|
|
57
|
+
<img
|
|
58
|
+
src={src}
|
|
59
|
+
className={className}
|
|
60
|
+
height={height}
|
|
61
|
+
width={width}
|
|
62
|
+
alt={alt}
|
|
63
|
+
style={style}
|
|
64
|
+
/>
|
|
65
|
+
</noscript>
|
|
66
|
+
</>
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
69
|
|