gatsby-core-theme 37.0.4 → 38.0.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/CHANGELOG.md +50 -0
- package/gatsby-node.mjs +6 -2
- package/package.json +1 -1
- package/src/components/atoms/pretty-link/index.js +38 -23
- package/src/components/molecules/content/index.js +58 -38
- package/src/constants/pick-keys.mjs +6 -2
- package/src/helpers/processor/operators.mjs +4 -0
- package/src/helpers/replaceMedia.js +72 -13
- package/src/helpers/replaceMedia.test.js +106 -22
- package/src/helpers/strings.js +6 -20
- package/src/helpers/strings.test.js +29 -17
- package/src/helpers/tracker.mjs +98 -57
- package/src/helpers/tracker.test.js +106 -49
- package/src/hooks/modal/index.js +4 -5
- package/src/hooks/modal/modal-content.js +14 -8
- package/src/hooks/modal/modal.module.scss +37 -30
- package/src/hooks/modal/modal.stories.js +9 -7
- package/src/hooks/modal/modal.test.js +9 -9
- package/src/hooks/modal/modalContext.js +6 -2
- package/src/pages/argentina/404/index.js +16 -0
- package/src/styles/utils/_extensions.scss +1 -0
- package/src/styles/utils/variables/_stack-order.scss +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
|
+
# [38.0.0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v37.0.5...v38.0.0) (2024-08-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* content fixes ([f59d532](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/f59d532223fb9a83dfe46d6e0814fb32ac7f20cc))
|
|
7
|
+
* content tracking api v1 ([da588f0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/da588f08dc72a06c751a67273929eed08f9a898c))
|
|
8
|
+
* env file ([7f65097](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/7f650979c7104b1d1256b7cb27c947638084378c))
|
|
9
|
+
* env file ([db6ddad](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/db6ddadcc25fd4bae4317ed472e3b5b6ce85d5c9))
|
|
10
|
+
* env same as demo matrix since we use the same data ([7d6be8b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/7d6be8bc04dbb1085558ad1277dc83ba30c75227))
|
|
11
|
+
* get latest changes ([977e2e9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/977e2e9de1d51e174f956d6a93fbe40cb1526bc7))
|
|
12
|
+
* pretty link ([2f225ed](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/2f225ed1e5592acf63f4207e6777d95be6463e82))
|
|
13
|
+
* redirects with full path ([6fd00e6](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6fd00e6ddf158ee826fea102732792d2acd970fb))
|
|
14
|
+
* small fix ([e78f601](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/e78f601e1c653478b4869a06b702629de648334f))
|
|
15
|
+
* test ([d98e826](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/d98e826c05d860f8f629bfb199602a1a62c1b157))
|
|
16
|
+
* test nested a with image and added clickedElement as link ([369f86f](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/369f86f30b0b4ba5442f4edd42cc036f67efd780))
|
|
17
|
+
* tests ([e09f445](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/e09f4452cfef79686672f25f18fa54db554ed669))
|
|
18
|
+
* tracking link check function ([5fbe0c5](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/5fbe0c5f2702733eda1c0c2272a5b4229ad42c69))
|
|
19
|
+
* update pick keys and operator mjs ([aa16a8a](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/aa16a8a0e17ae20af5ac8cd52ae3451bdd3ca5b7))
|
|
20
|
+
* update relations ([bdd2896](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/bdd2896aa25895d3509c63b9855171b8feb46de1))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Code Refactoring
|
|
24
|
+
|
|
25
|
+
* change in eslint ([b6891e1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/b6891e18ba62de0d44d6c2cb0c37a9f32760e88e))
|
|
26
|
+
* changes modal ([f483d9d](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/f483d9d970d4185b82419e61342285fe086d2b9d))
|
|
27
|
+
* changes to scss map-get ([a5824d7](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/a5824d749195746749784049448cc77b50017acf))
|
|
28
|
+
* changes to the modal ([81f5f42](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/81f5f42c5271839ee9ea43c0d2362960db2ee0ad))
|
|
29
|
+
* correction to fn name ([9ea53ac](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/9ea53ace3ace8eed0fd7aad0588c31326974b4f2))
|
|
30
|
+
* min with of modal ([360bccb](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/360bccbc246a837d92a75de50fd3f29194e34043))
|
|
31
|
+
* remove style ([44632b7](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/44632b78ed6fd739f4149ce02299d6f7d02d07da))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
* Merge branch 'tm-4651-info-grid' into 'master' ([6d97fff](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6d97fffba03b1014062ea1980c63bb1bcf766f19))
|
|
35
|
+
* Merge branch 'tm-4567-feedback-modal' into 'master' ([c161368](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c1613689e76995347be70145063a550518fb8439))
|
|
36
|
+
* Merge branch 'master' into tm-4567-feedback-modal ([c925752](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c925752077da95d781f48945b8ec95c645403a13))
|
|
37
|
+
* Merge branch 'tm-4722-redirects' into 'master' ([ebc2912](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/ebc2912b3885089e3b52380a6a56853bc9a7b9d3))
|
|
38
|
+
* Merge branch 'tm-4234-content-tracking-api' into 'master' ([71a222c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/71a222c0d8df21ffdf370f85b092da9860129abd))
|
|
39
|
+
* Merge branch 'master' into tm-4722-redirects ([97fa0c0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/97fa0c0af30609465032a1291d351ba1923f6927))
|
|
40
|
+
|
|
41
|
+
## [37.0.5](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v37.0.4...v37.0.5) (2024-08-28)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Bug Fixes
|
|
45
|
+
|
|
46
|
+
* update pick keys to include author name ([3751e59](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/3751e595d429660099866fd81753c2e78555763b))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
* Merge branch 'tm-4649-toplist' into 'master' ([994604f](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/994604fa5d42f63936c26fcfbb5c9b01cd989f42))
|
|
50
|
+
|
|
1
51
|
## [37.0.4](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v37.0.3...v37.0.4) (2024-08-27)
|
|
2
52
|
|
|
3
53
|
|
package/gatsby-node.mjs
CHANGED
|
@@ -167,15 +167,19 @@ export const createPages = async ({ actions: { createPage } }, themeOptions) =>
|
|
|
167
167
|
if (siteSettingsData.redirects) {
|
|
168
168
|
Object.entries(siteSettingsData.redirects).forEach(
|
|
169
169
|
([key, value]) => {
|
|
170
|
+
const normalizedFrom = value.from.replace(`https://www.${process.env.GATSBY_SITE_NAME}`, '');
|
|
171
|
+
const normalizedTo = value.to.replace(`https://www.${process.env.GATSBY_SITE_NAME}`, '');
|
|
172
|
+
|
|
170
173
|
if (![301, 302, 410].includes(parseInt(value.type))) return;
|
|
171
174
|
if ([301, 302].includes(parseInt(value.type))) {
|
|
172
175
|
const redirectName = parseInt(value.type) === 301 ? 'permanent' : 'redirect';
|
|
173
176
|
stream.write(
|
|
174
|
-
`rewrite (?i)^${
|
|
177
|
+
`rewrite (?i)^${normalizedFrom}/?$ ${normalizedTo.replace(/[{}]/g, '')} ${redirectName}; \n`
|
|
175
178
|
);
|
|
176
179
|
}
|
|
180
|
+
|
|
177
181
|
if (parseInt(value.type) === 410) {
|
|
178
|
-
stream.write(`location ~ /${
|
|
182
|
+
stream.write(`location ~ /${normalizedFrom} { return 410; } \n`);
|
|
179
183
|
}
|
|
180
184
|
}
|
|
181
185
|
)
|
package/package.json
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
/* eslint-disable react/jsx-no-target-blank */
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import PropTypes from 'prop-types'
|
|
4
|
-
import { globalHistory } from '@reach/router'
|
|
5
|
-
import { prettyTracker } from '~helpers/getters'
|
|
6
|
-
import { setCookie } from '~helpers/cookies'
|
|
7
|
-
import keygen from '~helpers/keygen'
|
|
8
|
-
import { getTrackingAPIParams } from '~helpers/tracker'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
import { globalHistory } from '@reach/router'
|
|
5
|
+
import { prettyTracker } from '~helpers/getters'
|
|
6
|
+
import { setCookie } from '~helpers/cookies'
|
|
7
|
+
import keygen from '~helpers/keygen'
|
|
8
|
+
import { getTrackingAPIParams } from '~helpers/tracker'
|
|
9
9
|
|
|
10
10
|
const PrettyLink = ({
|
|
11
11
|
operator,
|
|
12
|
+
directPrettyLink = null,
|
|
12
13
|
pageTemplate,
|
|
13
14
|
module,
|
|
14
15
|
tracker,
|
|
15
16
|
titleSuffix,
|
|
16
17
|
className,
|
|
17
18
|
children,
|
|
18
|
-
|
|
19
|
+
clickedElement = 'cta',
|
|
20
|
+
rel = 'nofollow sponsored'
|
|
19
21
|
}) => {
|
|
20
|
-
const prettyLink =
|
|
21
|
-
|
|
22
|
+
const prettyLink =
|
|
23
|
+
directPrettyLink || prettyTracker(operator, tracker, false, pageTemplate)
|
|
24
|
+
const referer =
|
|
25
|
+
typeof document !== 'undefined' && document?.referrer
|
|
26
|
+
? document.referrer
|
|
27
|
+
: ''
|
|
22
28
|
|
|
23
29
|
const onCTAClick = () => {
|
|
24
30
|
// eslint-disable-next-line no-unused-expressions
|
|
@@ -30,25 +36,28 @@ const PrettyLink = ({
|
|
|
30
36
|
pageTemplate,
|
|
31
37
|
module,
|
|
32
38
|
tracker,
|
|
33
|
-
|
|
39
|
+
clickedElement,
|
|
34
40
|
globalHistory.location.href,
|
|
35
41
|
referer
|
|
36
42
|
)
|
|
37
43
|
),
|
|
38
44
|
1,
|
|
39
45
|
'/'
|
|
40
|
-
)
|
|
46
|
+
)
|
|
41
47
|
|
|
42
|
-
if (
|
|
48
|
+
if (
|
|
49
|
+
process.env.ENABLE_PIXEL === 'true' &&
|
|
50
|
+
typeof window.fbq !== 'undefined'
|
|
51
|
+
) {
|
|
43
52
|
// Call fbq track event
|
|
44
|
-
window.fbq('track', 'InitiateCheckout', { keyID: keygen() })
|
|
53
|
+
window.fbq('track', 'InitiateCheckout', { keyID: keygen() })
|
|
45
54
|
}
|
|
46
|
-
}
|
|
55
|
+
}
|
|
47
56
|
|
|
48
57
|
return (
|
|
49
58
|
<a
|
|
50
59
|
href={prettyLink || '#'}
|
|
51
|
-
title={`${operator?.name} ${titleSuffix || ''}`.trimEnd()}
|
|
60
|
+
title={`${operator?.name || ''} ${titleSuffix || ''}`.trimEnd() || ''}
|
|
52
61
|
className={className}
|
|
53
62
|
target="_blank"
|
|
54
63
|
rel={rel}
|
|
@@ -57,20 +66,26 @@ const PrettyLink = ({
|
|
|
57
66
|
>
|
|
58
67
|
{children}
|
|
59
68
|
</a>
|
|
60
|
-
)
|
|
61
|
-
}
|
|
69
|
+
)
|
|
70
|
+
}
|
|
62
71
|
|
|
63
72
|
PrettyLink.propTypes = {
|
|
64
73
|
operator: PropTypes.shape({
|
|
65
|
-
name: PropTypes.string
|
|
74
|
+
name: PropTypes.string
|
|
66
75
|
}),
|
|
76
|
+
directPrettyLink: PropTypes.string,
|
|
67
77
|
pageTemplate: PropTypes.string,
|
|
68
78
|
module: PropTypes.string,
|
|
69
79
|
titleSuffix: PropTypes.string,
|
|
70
80
|
tracker: PropTypes.string,
|
|
71
81
|
className: PropTypes.string,
|
|
72
|
-
children: PropTypes.oneOfType([
|
|
73
|
-
|
|
74
|
-
|
|
82
|
+
children: PropTypes.oneOfType([
|
|
83
|
+
PropTypes.arrayOf(PropTypes.node),
|
|
84
|
+
PropTypes.node,
|
|
85
|
+
PropTypes.any
|
|
86
|
+
]),
|
|
87
|
+
clickedElement: PropTypes.string,
|
|
88
|
+
rel: PropTypes.string
|
|
89
|
+
}
|
|
75
90
|
|
|
76
|
-
export default PrettyLink
|
|
91
|
+
export default PrettyLink
|
|
@@ -1,73 +1,89 @@
|
|
|
1
1
|
/* eslint-disable camelcase */
|
|
2
2
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
3
|
-
import React, { useState } from 'react'
|
|
4
|
-
import parse from 'html-react-parser'
|
|
5
|
-
import PropTypes from 'prop-types'
|
|
6
|
-
import { IoIosArrowDown } from '@react-icons/all-files/io/IoIosArrowDown'
|
|
7
|
-
import replaceMedia from '../../../helpers/replaceMedia'
|
|
8
|
-
import styles from './content.module.scss'
|
|
9
|
-
import lists from './lists/lists.module.scss'
|
|
10
|
-
import table from './table/table.module.scss'
|
|
11
|
-
import frame from './frame/frame.module.scss'
|
|
12
|
-
import blockquote from './blockquote.module.scss'
|
|
3
|
+
import React, { useState } from 'react'
|
|
4
|
+
import parse from 'html-react-parser'
|
|
5
|
+
import PropTypes from 'prop-types'
|
|
6
|
+
import { IoIosArrowDown } from '@react-icons/all-files/io/IoIosArrowDown'
|
|
7
|
+
import replaceMedia from '../../../helpers/replaceMedia'
|
|
8
|
+
import styles from './content.module.scss'
|
|
9
|
+
import lists from './lists/lists.module.scss'
|
|
10
|
+
import table from './table/table.module.scss'
|
|
11
|
+
import frame from './frame/frame.module.scss'
|
|
12
|
+
import blockquote from './blockquote.module.scss'
|
|
13
13
|
|
|
14
14
|
const Content = ({
|
|
15
15
|
module,
|
|
16
16
|
isHomepageFirstModule = false,
|
|
17
17
|
isModuleIntroduction = '',
|
|
18
18
|
page,
|
|
19
|
+
moduleName = 'content',
|
|
19
20
|
isContentCollapsible = false,
|
|
20
21
|
icon = <IoIosArrowDown />,
|
|
21
|
-
moduleWidth = 960
|
|
22
|
+
moduleWidth = 960
|
|
22
23
|
}) => {
|
|
23
|
-
const { show_more_label, show_more_enabled } = module || {}
|
|
24
|
+
const { show_more_label, show_more_enabled } = module || {}
|
|
24
25
|
|
|
25
|
-
const
|
|
26
|
+
const pageTemplate = page?.template
|
|
27
|
+
|
|
28
|
+
const [showMore, setShowMore] = useState(false)
|
|
26
29
|
|
|
27
30
|
const handleChange = () => {
|
|
28
|
-
setShowMore(!showMore)
|
|
29
|
-
}
|
|
31
|
+
setShowMore(!showMore)
|
|
32
|
+
}
|
|
30
33
|
|
|
31
34
|
const switchStyle = (style) => {
|
|
32
35
|
switch (style) {
|
|
33
36
|
case 'template_two':
|
|
34
|
-
return `${table.templateTwo || ''}
|
|
37
|
+
return `${table.templateTwo || ''}`
|
|
35
38
|
case 'template_three':
|
|
36
|
-
return `${table.templateOne || ''} ${frame.frame || ''}
|
|
39
|
+
return `${table.templateOne || ''} ${frame.frame || ''}`
|
|
37
40
|
default:
|
|
38
|
-
return `${table.templateOne || ''}
|
|
41
|
+
return `${table.templateOne || ''}`
|
|
39
42
|
}
|
|
40
|
-
}
|
|
43
|
+
}
|
|
41
44
|
|
|
42
|
-
const mainContent = (content, customClassName = ''
|
|
45
|
+
const mainContent = (content, customClassName = '') => (
|
|
43
46
|
<div
|
|
44
|
-
className={` ${styles.content || ''} ${lists.ul || ''} ${
|
|
47
|
+
className={` ${styles.content || ''} ${lists.ul || ''} ${
|
|
48
|
+
blockquote.blockquote || ''
|
|
49
|
+
}
|
|
45
50
|
${switchStyle(module.style) || ''} ${
|
|
46
51
|
isHomepageFirstModule ? styles.homepageFirstModuleContent || '' : ''
|
|
47
|
-
} ${
|
|
52
|
+
} ${
|
|
53
|
+
isModuleIntroduction ? styles.moduleIntroMargin || '' : ''
|
|
54
|
+
} ${customClassName}
|
|
48
55
|
`}
|
|
49
56
|
>
|
|
50
57
|
{parse(content, {
|
|
51
|
-
replace: (node) =>
|
|
58
|
+
replace: (node) =>
|
|
59
|
+
replaceMedia(node, moduleWidth, moduleName, pageTemplate)
|
|
52
60
|
})}
|
|
53
61
|
</div>
|
|
54
|
-
)
|
|
62
|
+
)
|
|
55
63
|
|
|
56
|
-
const mainContentTwo = (
|
|
64
|
+
const mainContentTwo = (
|
|
65
|
+
content,
|
|
66
|
+
customClassName = '',
|
|
67
|
+
showMoreText = false
|
|
68
|
+
) => (
|
|
57
69
|
<div
|
|
58
|
-
className={` ${styles.content || ''} ${lists.ul || ''} ${
|
|
70
|
+
className={` ${styles.content || ''} ${lists.ul || ''} ${
|
|
71
|
+
blockquote.blockquote || ''
|
|
72
|
+
}
|
|
59
73
|
${showMore && !isContentCollapsible ? styles.showMore : ''}
|
|
60
74
|
${switchStyle(module.style) || ''} ${
|
|
61
75
|
isHomepageFirstModule ? styles.homepageFirstModuleContent || '' : ''
|
|
62
|
-
} ${
|
|
76
|
+
} ${
|
|
77
|
+
isModuleIntroduction ? styles.moduleIntroMargin || '' : ''
|
|
78
|
+
} ${customClassName}
|
|
63
79
|
${showMoreText && !showMore ? styles.hide : ''}
|
|
64
80
|
`}
|
|
65
81
|
>
|
|
66
82
|
{parse(content, {
|
|
67
|
-
replace: (node) => replaceMedia(node, page, {}, moduleWidth)
|
|
83
|
+
replace: (node) => replaceMedia(node, page, {}, moduleWidth)
|
|
68
84
|
})}
|
|
69
85
|
</div>
|
|
70
|
-
)
|
|
86
|
+
)
|
|
71
87
|
|
|
72
88
|
return show_more_enabled !== '1' || module.show_more_content == null ? (
|
|
73
89
|
mainContent(module.value)
|
|
@@ -77,9 +93,12 @@ const Content = ({
|
|
|
77
93
|
<button
|
|
78
94
|
type="button"
|
|
79
95
|
className={`${
|
|
80
|
-
isContentCollapsible
|
|
96
|
+
isContentCollapsible
|
|
97
|
+
? styles.showMoreTwoButton || ''
|
|
98
|
+
: styles.showMoreButton || ''
|
|
81
99
|
} ${(!isContentCollapsible && showMore && styles.hide) || ''} ${
|
|
82
|
-
(showMore && isContentCollapsible && styles.showMoreTwoButtonOpen) ||
|
|
100
|
+
(showMore && isContentCollapsible && styles.showMoreTwoButtonOpen) ||
|
|
101
|
+
''
|
|
83
102
|
}`}
|
|
84
103
|
onClick={handleChange}
|
|
85
104
|
title="showMoreContentButton"
|
|
@@ -95,8 +114,8 @@ const Content = ({
|
|
|
95
114
|
true
|
|
96
115
|
)}
|
|
97
116
|
</>
|
|
98
|
-
)
|
|
99
|
-
}
|
|
117
|
+
)
|
|
118
|
+
}
|
|
100
119
|
|
|
101
120
|
Content.propTypes = {
|
|
102
121
|
module: PropTypes.shape({
|
|
@@ -105,14 +124,15 @@ Content.propTypes = {
|
|
|
105
124
|
module_title: PropTypes.string,
|
|
106
125
|
value: PropTypes.string,
|
|
107
126
|
style: PropTypes.string,
|
|
108
|
-
show_more_content: PropTypes.string
|
|
127
|
+
show_more_content: PropTypes.string
|
|
109
128
|
}),
|
|
110
|
-
page: PropTypes.shape({}),
|
|
129
|
+
page: PropTypes.shape({ template: PropTypes.string }),
|
|
130
|
+
moduleName: PropTypes.string,
|
|
111
131
|
isHomepageFirstModule: PropTypes.bool,
|
|
112
132
|
isModuleIntroduction: PropTypes.string,
|
|
113
133
|
isContentCollapsible: PropTypes.bool,
|
|
114
134
|
icon: PropTypes.node,
|
|
115
|
-
moduleWidth: PropTypes.node
|
|
116
|
-
}
|
|
135
|
+
moduleWidth: PropTypes.node
|
|
136
|
+
}
|
|
117
137
|
|
|
118
|
-
export default Content
|
|
138
|
+
export default Content
|
|
@@ -39,7 +39,10 @@ export const topListPickKeys = [
|
|
|
39
39
|
'founded',
|
|
40
40
|
'ribbons',
|
|
41
41
|
'owner',
|
|
42
|
-
'support_types'
|
|
42
|
+
'support_types',
|
|
43
|
+
'authorName',
|
|
44
|
+
'authorPath',
|
|
45
|
+
'updatedAt'
|
|
43
46
|
];
|
|
44
47
|
|
|
45
48
|
export const pickTrackerOperatorKeys = [
|
|
@@ -82,7 +85,8 @@ export const pickRelationKeys = {
|
|
|
82
85
|
'url',
|
|
83
86
|
'games_amount',
|
|
84
87
|
'review_link',
|
|
85
|
-
'payout_time'
|
|
88
|
+
'payout_time',
|
|
89
|
+
'support_types'
|
|
86
90
|
],
|
|
87
91
|
game: [
|
|
88
92
|
'game_provider',
|
|
@@ -80,6 +80,10 @@ export function sanitizeOperatorData(
|
|
|
80
80
|
clone.authorImageObject = operatorPage[0].author.image_object;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
if (operatorPage.length >= 1) {
|
|
84
|
+
clone.updatedAt = operatorPage[0].updated_at;
|
|
85
|
+
}
|
|
86
|
+
|
|
83
87
|
// Set Logo Url
|
|
84
88
|
clone.logo =
|
|
85
89
|
operatorClone.logo_url_object ||
|
|
@@ -1,32 +1,91 @@
|
|
|
1
1
|
/* eslint-disable react/destructuring-assignment */
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import Iframe from 'gatsby-core-theme/src/components/atoms/iframe'
|
|
4
|
-
import
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import Iframe from 'gatsby-core-theme/src/components/atoms/iframe'
|
|
4
|
+
import { isTrackerLink } from 'gatsby-core-theme/src/helpers/tracker.mjs'
|
|
5
|
+
import processImageNode from './processImageNode.js'
|
|
6
|
+
import PrettyLink from '~atoms/pretty-link'
|
|
5
7
|
|
|
6
|
-
export default (node, moduleWidth = 960) => {
|
|
8
|
+
export default (node, moduleWidth = 960, moduleName, pageTemplate) => {
|
|
7
9
|
if (node.name === 'iframe') {
|
|
8
|
-
return <Iframe src={node.attribs.src}
|
|
10
|
+
return <Iframe src={node.attribs.src} />
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
if (node.name === 'img') {
|
|
12
|
-
return processImageNode(node, moduleWidth)
|
|
14
|
+
return processImageNode(node, moduleWidth)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (node.name === 'a' && isTrackerLink(node?.attribs?.href || '')) {
|
|
18
|
+
// Helper function to convert style string to an object
|
|
19
|
+
const convertStyleStringToObject = (styleString) =>
|
|
20
|
+
styleString.split(';').reduce((acc, style) => {
|
|
21
|
+
const [key, value] = style.split(':')
|
|
22
|
+
if (key && value) {
|
|
23
|
+
acc[key.trim()] = value.trim()
|
|
24
|
+
}
|
|
25
|
+
return acc
|
|
26
|
+
}, {})
|
|
27
|
+
|
|
28
|
+
// Helper function to recursively render children nodes
|
|
29
|
+
const renderChildren = (children) =>
|
|
30
|
+
children.map((child) => {
|
|
31
|
+
if (child.type === 'tag') {
|
|
32
|
+
const styleObject = child.attribs?.style
|
|
33
|
+
? convertStyleStringToObject(child.attribs.style)
|
|
34
|
+
: null
|
|
35
|
+
|
|
36
|
+
const { style, ...attribsWithoutStyle } = child.attribs
|
|
37
|
+
|
|
38
|
+
// Assuming `child.attribs.id` or a similar unique property exists
|
|
39
|
+
const key = child.attribs.id || child.name
|
|
40
|
+
|
|
41
|
+
if (child.name === 'img') {
|
|
42
|
+
processImageNode(child, moduleWidth)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return React.createElement(
|
|
46
|
+
child.name,
|
|
47
|
+
{ key, ...attribsWithoutStyle, style: styleObject },
|
|
48
|
+
child.name !== 'img' && child.name !== 'br'
|
|
49
|
+
? renderChildren(child.children || [])
|
|
50
|
+
: null
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return child?.data
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<PrettyLink
|
|
59
|
+
directPrettyLink={node?.attribs?.href}
|
|
60
|
+
pageTemplate={pageTemplate}
|
|
61
|
+
module={moduleName}
|
|
62
|
+
tracker={module?.tracking_link_name || 'main'}
|
|
63
|
+
className="content-module-gtm"
|
|
64
|
+
clickedElement="link"
|
|
65
|
+
rel={node?.attribs?.rel}
|
|
66
|
+
>
|
|
67
|
+
{node.children === 'text'
|
|
68
|
+
? node.children[0]?.data
|
|
69
|
+
: renderChildren(node?.children || [])}
|
|
70
|
+
</PrettyLink>
|
|
71
|
+
)
|
|
13
72
|
}
|
|
14
73
|
|
|
15
74
|
if (node.name === 'p') {
|
|
16
|
-
const hasChildImg = node?.children.find((child) => child?.name === 'img')
|
|
75
|
+
const hasChildImg = node?.children.find((child) => child?.name === 'img')
|
|
17
76
|
|
|
18
77
|
if (hasChildImg) {
|
|
19
|
-
hasChildImg.attribs.style = ''
|
|
20
|
-
return hasChildImg
|
|
78
|
+
hasChildImg.attribs.style = ''
|
|
79
|
+
return hasChildImg
|
|
21
80
|
}
|
|
22
81
|
}
|
|
23
82
|
|
|
24
83
|
// Add tab index for tables for accessibility
|
|
25
84
|
if (node.name === 'table') {
|
|
26
|
-
node.attribs.tabIndex = 0
|
|
85
|
+
node.attribs.tabIndex = 0
|
|
27
86
|
|
|
28
|
-
return node
|
|
87
|
+
return node
|
|
29
88
|
}
|
|
30
89
|
|
|
31
|
-
return null
|
|
32
|
-
}
|
|
90
|
+
return null
|
|
91
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import transformNode from './replaceMedia'
|
|
1
|
+
import transformNode from './replaceMedia'
|
|
2
2
|
|
|
3
3
|
describe('replaceMedia function', () => {
|
|
4
4
|
it('iframe', async () => {
|
|
5
|
-
const node = { name: 'iframe', attribs: { src: 'https://iframe.com' } }
|
|
6
|
-
const transformedNode = await transformNode(node, {}, {})
|
|
7
|
-
expect(transformedNode.type.name).toBe('Iframe')
|
|
8
|
-
})
|
|
5
|
+
const node = { name: 'iframe', attribs: { src: 'https://iframe.com' } }
|
|
6
|
+
const transformedNode = await transformNode(node, {}, {})
|
|
7
|
+
expect(transformedNode.type.name).toBe('Iframe')
|
|
8
|
+
})
|
|
9
9
|
|
|
10
10
|
it('img', () => {
|
|
11
11
|
const node = {
|
|
@@ -15,24 +15,108 @@ describe('replaceMedia function', () => {
|
|
|
15
15
|
class: 'content-image--align-center',
|
|
16
16
|
width: '300px',
|
|
17
17
|
height: '200px',
|
|
18
|
-
alt: 'Alt text'
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
const transformedNode = transformNode(node, {}, {})
|
|
22
|
-
expect(transformedNode.type.name).toBe('LazyImage')
|
|
23
|
-
expect(transformedNode.props.src).toBe(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
expect(transformedNode.props.
|
|
27
|
-
expect(transformedNode.props.
|
|
28
|
-
|
|
18
|
+
alt: 'Alt text'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const transformedNode = transformNode(node, {}, {})
|
|
22
|
+
expect(transformedNode.type.name).toBe('LazyImage')
|
|
23
|
+
expect(transformedNode.props.src).toBe(
|
|
24
|
+
'https://cdn.images.com/fit-in/300x200/image.jpg'
|
|
25
|
+
)
|
|
26
|
+
expect(transformedNode.props.width).toBe('300')
|
|
27
|
+
expect(transformedNode.props.height).toBe('200')
|
|
28
|
+
expect(transformedNode.props.alt).toBe('Alt text')
|
|
29
|
+
expect(transformedNode.props.className).toBe('alignCenter')
|
|
30
|
+
})
|
|
29
31
|
|
|
30
32
|
it('transforms p node with img child correctly', () => {
|
|
31
33
|
const node = {
|
|
32
34
|
name: 'p',
|
|
33
|
-
children: [
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
children: [
|
|
36
|
+
{ name: 'img', attribs: { src: 'https://cdn.images.com/image.jpg' } }
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
const transformedNode = transformNode(node, {}, {})
|
|
40
|
+
expect(transformedNode.attribs.style).toBe('')
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('transforms a tag with tracker link correctly', () => {
|
|
44
|
+
process.env.TRACKER_LINK_FORMAT_MAIN = '[za_en],[visit],type,short_name'
|
|
45
|
+
const node = {
|
|
46
|
+
name: 'a',
|
|
47
|
+
attribs: {
|
|
48
|
+
href: 'https://www.playcasino.co.za/za_en/visit/10bet',
|
|
49
|
+
style: 'color: red; text-decoration: none;'
|
|
50
|
+
},
|
|
51
|
+
children: [{ type: 'text', data: 'Click me' }]
|
|
52
|
+
}
|
|
53
|
+
const transformedNode = transformNode(
|
|
54
|
+
node,
|
|
55
|
+
960,
|
|
56
|
+
'content',
|
|
57
|
+
'default'
|
|
58
|
+
)
|
|
59
|
+
expect(transformedNode.props.directPrettyLink).toBe(
|
|
60
|
+
'https://www.playcasino.co.za/za_en/visit/10bet'
|
|
61
|
+
)
|
|
62
|
+
expect(transformedNode.props.className).toBe('content-module-gtm')
|
|
63
|
+
expect(transformedNode.props.clickedElement).toBe('link')
|
|
64
|
+
expect(transformedNode.props.module).toBe('content')
|
|
65
|
+
expect(transformedNode.props.pageTemplate).toBe('default')
|
|
66
|
+
expect(transformedNode.props.tracker).toBe('main')
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('transforms an anchor tag with an image correctly', () => {
|
|
70
|
+
const node = {
|
|
71
|
+
name: 'a',
|
|
72
|
+
attribs: {
|
|
73
|
+
href: 'https://www.playcasino.co.za/za_en/visit/10bet',
|
|
74
|
+
style: 'color: red; text-decoration: none;',
|
|
75
|
+
rel: 'noopener noreferrer'
|
|
76
|
+
},
|
|
77
|
+
children: [
|
|
78
|
+
{
|
|
79
|
+
name: 'img',
|
|
80
|
+
type: 'tag',
|
|
81
|
+
attribs: {
|
|
82
|
+
src: 'https://assets-srv.s3.eu-west-1.amazonaws.com/1718708348/springbok-casino-bonus.jpg',
|
|
83
|
+
alt: 'Alt text',
|
|
84
|
+
style: 'width: 100px; height: 50px;',
|
|
85
|
+
class: 'content-image--align-center',
|
|
86
|
+
width: '100',
|
|
87
|
+
height: '50'
|
|
88
|
+
},
|
|
89
|
+
children: []
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const transformedNode = transformNode(
|
|
95
|
+
node,
|
|
96
|
+
960,
|
|
97
|
+
'content',
|
|
98
|
+
'default'
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
// Check that the transformed node is a PrettyLink component
|
|
102
|
+
// expect(transformedNode.type).toBe(PrettyLink);
|
|
103
|
+
|
|
104
|
+
// Check that the props are correctly set
|
|
105
|
+
expect(transformedNode.props.directPrettyLink).toBe(
|
|
106
|
+
'https://www.playcasino.co.za/za_en/visit/10bet'
|
|
107
|
+
)
|
|
108
|
+
expect(transformedNode.props.className).toBe('content-module-gtm')
|
|
109
|
+
expect(transformedNode.props.rel).toBe('noopener noreferrer')
|
|
110
|
+
expect(transformedNode.props.children).toHaveLength(1)
|
|
111
|
+
|
|
112
|
+
// Check the image within the PrettyLink
|
|
113
|
+
const imageNode = transformedNode.props.children[0]
|
|
114
|
+
// expect(imageNode.type).toBe(LazyImage);
|
|
115
|
+
expect(imageNode.props.src).toBe(
|
|
116
|
+
'https://assets-srv.s3.eu-west-1.amazonaws.com/1718708348/springbok-casino-bonus.jpg'
|
|
117
|
+
)
|
|
118
|
+
expect(imageNode.props.alt).toBe('Alt text')
|
|
119
|
+
expect(imageNode.props.width).toBe('100')
|
|
120
|
+
expect(imageNode.props.height).toBe('50')
|
|
121
|
+
})
|
|
122
|
+
})
|