gatsby-core-theme 44.0.39 → 44.0.41
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 +38 -0
- package/gatsby-node.mjs +1 -1
- package/package.json +1 -1
- package/src/components/atoms/author-box/details/index.js +2 -1
- package/src/components/atoms/header-operator-bannner/index.js +2 -1
- package/src/components/atoms/notifications/notification-items/cards-v2/index.js +5 -4
- package/src/components/atoms/notifications/notification-items/spotlight/index.js +5 -4
- package/src/components/molecules/carousel/default-slide/index.js +1 -1
- package/src/components/molecules/header/variants/default/template-one/index.js +5 -4
- package/src/components/molecules/header/variants/operator/template-one-two/index.js +7 -6
- package/src/components/molecules/header/variants/slot/template-one/index.js +4 -3
- package/src/components/molecules/link-list/index.js +2 -1
- package/src/components/molecules/spotlights_v2/icon/template-one/index.js +4 -3
- package/src/components/molecules/spotlights_v2/image/template-one/index.js +4 -3
- package/src/components/molecules/spotlights_v2/image/template-two/index.js +4 -3
- package/src/components/molecules/spotlights_v2/image-text/template-one/index.js +3 -2
- package/src/components/molecules/spotlights_v2/image-text/template-three/item/index.js +4 -4
- package/src/components/molecules/spotlights_v2/image-text/template-two/index.js +3 -2
- package/src/components/molecules/toplist/default-row/index.js +4 -3
- package/src/components/molecules/toplist/header/index.js +2 -1
- package/src/components/organisms/head/customData.js +1 -0
- package/src/components/organisms/head/head.test.js +21 -57
- package/src/components/organisms/head/index.js +38 -81
- package/src/components/pages/tracker/index-ssr.js +2 -1
- package/src/components/pages/tracker/index.js +2 -1
- package/src/constants/metaTags.js +15 -0
- package/src/constants/pick-keys.mjs +3 -2
- package/src/helpers/getters.mjs +8 -14
- package/src/helpers/getters.test.js +30 -10
- package/src/helpers/head.js +51 -0
- package/src/helpers/head.test.js +50 -0
- package/src/helpers/image.js +26 -0
- package/src/helpers/image.test.js +21 -0
- package/src/helpers/schema.js +7 -4
- package/src/helpers/schema.test.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
+
## [44.0.41](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.0.40...v44.0.41) (2025-05-20)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* moved the alt function in a seperate file ([5cbee51](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/5cbee51b7c6d5afd38ec6cec048e4db6e13d7565))
|
|
7
|
+
* moved the alt function in a seperate file ([ddb1adb](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/ddb1adb1db4c5286464d576da4b8568655a91de9))
|
|
8
|
+
* moved the alt function in a seperate file ([bb4af76](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/bb4af76c7d4499593c58e7ff7b4fcb0844ad671d))
|
|
9
|
+
* operator images alt text translations ([744a9bf](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/744a9bf7115d9d82323c79f0cb0c02d5a3d271cf))
|
|
10
|
+
* pass the page data to custome head function ([dc4293b](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/dc4293b3b7d7ae42ffe1634ca5c694f3fa126b0d))
|
|
11
|
+
* update pick keys constant to include rating comments ([bac40c0](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/bac40c01be69c9fb8b097aeca9733afc74e3d498))
|
|
12
|
+
* variable reassignment ([1e7acf3](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/1e7acf36a709c7d157f438acf9f3a70011ee6af4))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
* Merge branch 'tm-5468-alt-text-translations' into 'master' ([fb65d5d](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/fb65d5dc534d30d45c21013a48f782564f11362c))
|
|
16
|
+
* Merge branch 'tm-5433-ratings-template-block' into 'master' ([88c210d](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/88c210da286370e223aa66a5235bd7ca81b0573f))
|
|
17
|
+
|
|
18
|
+
## [44.0.40](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.0.39...v44.0.40) (2025-05-19)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* add customeData ([b5936fa](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/b5936fac9e928cd78b70f48a2521ba9eb6118c20))
|
|
24
|
+
* add validation for archive pages ([5561b9c](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/5561b9c2540ffe7f9917e6c2cba4d3cec7055e67))
|
|
25
|
+
* centralaize the meta data ([3a21c76](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/3a21c76f694482f587a31e26bd64eb8bbd5f78b1))
|
|
26
|
+
* clean up the function ([91773ef](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/91773ef08cc1b40b5ca388715941eb033f3ae466))
|
|
27
|
+
* fix aleternative links default ([e97e985](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/e97e9854498f669c423597b4d68c9f6d8ff105a5))
|
|
28
|
+
* fix issues ([dbcfcec](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/dbcfcec545657a18ac35296033933a7728b6b0fd))
|
|
29
|
+
* fix meta data ([c29976b](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/c29976bf95cc763695099ceec8044f5066a17dfa))
|
|
30
|
+
* fix test ([3711007](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/3711007e4427f057ff3a0a0019e19836aae1e304))
|
|
31
|
+
* update meta data ([2888046](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/2888046a7c512fc01d83159f06ab48be6f6d1546))
|
|
32
|
+
* update the schema ([8eda362](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/8eda362674e2fa2cf2e2f40d37a067944163e0f2))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
* Merge branch 'tm-5213-head' into 'master' ([90fb1d7](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/90fb1d793113ffbda45ea6dc4f43bbcfd5052424))
|
|
36
|
+
* Merge branch 'master' into 'tm-5213-head' ([28a6b72](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/28a6b72f1c15bca3bd755ba93863df48d0b91e9a))
|
|
37
|
+
* Merge branch 'master' into tm-5213-head ([a14780f](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/commit/a14780ff0d5b36080e94970c6ad674660c255f9e))
|
|
38
|
+
|
|
1
39
|
## [44.0.39](https://gitlab.com/g2m-gentoo/team-floyd/themes/gatsby-themes/compare/v44.0.38...v44.0.39) (2025-05-15)
|
|
2
40
|
|
|
3
41
|
|
package/gatsby-node.mjs
CHANGED
|
@@ -88,7 +88,7 @@ function createArchivePage(
|
|
|
88
88
|
|
|
89
89
|
if (process.env.CUSTOM_CONTENT_PAGES_PATH && archivePages) {
|
|
90
90
|
// eslint-disable-next-line array-callback-return
|
|
91
|
-
archivePages = archivePages.filter((item) => {
|
|
91
|
+
archivePages = archivePages && archivePages.filter((item) => {
|
|
92
92
|
if (item.path.includes(process.env.CUSTOM_CONTENT_PAGES_PATH)) {
|
|
93
93
|
return item;
|
|
94
94
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import { imagePrettyUrl
|
|
4
|
+
import { imagePrettyUrl } from '~helpers/getters';
|
|
5
|
+
import { getAltText } from '~helpers/image';
|
|
5
6
|
import styles from './author-details.module.scss';
|
|
6
7
|
import LazyImage from '~hooks/lazy-image';
|
|
7
8
|
import Link from '~hooks/link';
|
|
@@ -4,7 +4,8 @@ import LazyImage from '~hooks/lazy-image'
|
|
|
4
4
|
import useTranslate from '~hooks/useTranslate/useTranslate'
|
|
5
5
|
import Bonus from '~molecules/bonus-box/template-three'
|
|
6
6
|
import { TrackingKeys } from '~constants/tracking-api'
|
|
7
|
-
import {
|
|
7
|
+
import { imagePrettyUrl } from '~helpers/getters'
|
|
8
|
+
import { getAltText } from '~helpers/image';
|
|
8
9
|
|
|
9
10
|
import styles from './header-operator-bannner.module.scss'
|
|
10
11
|
import { trackerLinkActive } from "~helpers/tracker.mjs";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
3
|
+
import LazyImage from '~hooks/lazy-image';
|
|
4
|
+
import keygen from '~helpers/keygen';
|
|
5
|
+
import Link from '~hooks/link';
|
|
6
|
+
import { imagePrettyUrl, getExtraField } from '~helpers/getters';
|
|
7
|
+
import { getAltText, getImageFilename } from '~helpers/image';
|
|
7
8
|
import useTranslate from '~hooks/useTranslate/useTranslate';
|
|
8
9
|
import CloseIcon from '~images/icons/close';
|
|
9
10
|
import styles from './notification-items.module.scss';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { imagePrettyUrl
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
3
|
+
import { imagePrettyUrl } from '~helpers/getters';
|
|
4
|
+
import { getAltText, getImageFilename } from '~helpers/image';
|
|
5
|
+
import LazyImage from '~hooks/lazy-image';
|
|
6
|
+
import keygen from '~helpers/keygen';
|
|
7
|
+
import Link from '~hooks/link';
|
|
7
8
|
import useTranslate from '~hooks/useTranslate/useTranslate';
|
|
8
9
|
import CloseIcon from '~images/icons/close';
|
|
9
10
|
import styles from './notification-items.module.scss';
|
|
@@ -5,7 +5,7 @@ import React from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
|
|
7
7
|
import ResponsiveImages from '~hooks/responsive-images';
|
|
8
|
-
import {
|
|
8
|
+
import { getAltText } from '~helpers/image';
|
|
9
9
|
import styles from './default-slide.module.scss';
|
|
10
10
|
|
|
11
11
|
const Slide = ({
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { FaArrowRight } from '@react-icons/all-files/fa/FaArrowRight';
|
|
5
|
-
import LazyImage from '
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
5
|
+
import LazyImage from '~hooks/lazy-image';
|
|
6
|
+
import { getAltText } from '~helpers/image';
|
|
7
|
+
import Button from '~atoms/button/button';
|
|
8
|
+
import { imagePrettyUrl, getExtraField } from '~helpers/getters';
|
|
9
|
+
import VariableComponent from '~molecules/header/variants/default/variables';
|
|
9
10
|
import styles from './template-one.module.scss';
|
|
10
11
|
|
|
11
12
|
export default function TemplateOne({
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
4
|
-
import { imagePrettyUrl, getAltText } from 'gatsby-core-theme/src/helpers/getters';
|
|
5
|
-
import LazyImage from 'gatsby-core-theme/src/hooks/lazy-image';
|
|
6
|
-
import StarRating from 'gatsby-core-theme/src/components/molecules/star-rating/one-star';
|
|
7
4
|
import { FaStar } from '@react-icons/all-files/fa/FaStar';
|
|
5
|
+
import { imagePrettyUrl } from '~helpers/getters';
|
|
6
|
+
import { getAltText } from '~helpers/image';
|
|
7
|
+
import LazyImage from '~hooks/lazy-image';
|
|
8
|
+
import StarRating from '~molecules/star-rating/one-star';
|
|
8
9
|
import useTranslate from '~hooks/useTranslate/useTranslate';
|
|
9
10
|
import Verify from '~images/icons/verify';
|
|
10
|
-
import Rating from '
|
|
11
|
-
import OperatorBanner from '
|
|
11
|
+
import Rating from '~atoms/ratings';
|
|
12
|
+
import OperatorBanner from '~atoms/header-operator-bannner';
|
|
12
13
|
import VariableComponent from '../variables';
|
|
13
14
|
import styles from './template-one-two.module.scss';
|
|
14
15
|
import { TrackingKeys } from '~constants/tracking-api'
|
|
15
16
|
import PrettyLink from '~atoms/pretty-link';
|
|
16
|
-
import Ribbons from '
|
|
17
|
+
import Ribbons from '~atoms/ribbons';
|
|
17
18
|
|
|
18
19
|
const TemplateOneTwo = ({
|
|
19
20
|
relation,
|
|
@@ -2,9 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
4
|
import { FaStar } from '@react-icons/all-files/fa/FaStar';
|
|
5
|
-
import { imagePrettyUrl
|
|
6
|
-
import OperatorBanner from '
|
|
7
|
-
import Rating from '
|
|
5
|
+
import { imagePrettyUrl } from '~helpers/getters';
|
|
6
|
+
import OperatorBanner from '~atoms/header-operator-bannner';
|
|
7
|
+
import Rating from '~atoms/ratings';
|
|
8
|
+
import { getAltText } from '~helpers/image';
|
|
8
9
|
import Verify from '~images/icons/verify';
|
|
9
10
|
import { TrackingKeys } from '~constants/tracking-api'
|
|
10
11
|
import styles from './slot.module.scss';
|
|
@@ -4,7 +4,8 @@ import React from 'react';
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
|
|
6
6
|
import keygen from '~helpers/keygen';
|
|
7
|
-
import { imagePrettyUrl
|
|
7
|
+
import { imagePrettyUrl } from '~helpers/getters';
|
|
8
|
+
import { getAltText } from '~helpers/image';
|
|
8
9
|
import Link from '~hooks/link';
|
|
9
10
|
import LazyImage from '~hooks/lazy-image';
|
|
10
11
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import keygen from '~helpers/keygen';
|
|
4
|
-
import LazyImage from '
|
|
5
|
-
import Link from '
|
|
6
|
-
import {
|
|
4
|
+
import LazyImage from '~hooks/lazy-image';
|
|
5
|
+
import Link from '~hooks/link';
|
|
6
|
+
import { imagePrettyUrl } from '~helpers/getters.mjs';
|
|
7
|
+
import { getAltText } from '~helpers/image';
|
|
7
8
|
import styles from './template-one.module.scss';
|
|
8
9
|
import useTranslate from '~hooks/useTranslate/useTranslate';
|
|
9
10
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import keygen from '~helpers/keygen';
|
|
4
|
-
import LazyImage from '
|
|
5
|
-
import Link from '
|
|
6
|
-
import {
|
|
4
|
+
import LazyImage from '~hooks/lazy-image';
|
|
5
|
+
import Link from '~hooks/link';
|
|
6
|
+
import { imagePrettyUrl } from '~helpers/getters.mjs';
|
|
7
|
+
import { getAltText } from '~helpers/image';
|
|
7
8
|
import styles from './template-one.module.scss';
|
|
8
9
|
import useTranslate from '~hooks/useTranslate/useTranslate';
|
|
9
10
|
|
|
@@ -2,9 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { FaArrowRight } from '@react-icons/all-files/fa/FaArrowRight';
|
|
4
4
|
import keygen from '~helpers/keygen';
|
|
5
|
-
import LazyImage from '
|
|
6
|
-
import Link from '
|
|
7
|
-
import {
|
|
5
|
+
import LazyImage from '~hooks/lazy-image';
|
|
6
|
+
import Link from '~hooks/link';
|
|
7
|
+
import { imagePrettyUrl } from '~helpers/getters.mjs';
|
|
8
|
+
import { getAltText } from '~helpers/image';
|
|
8
9
|
import styles from './template-two.module.scss';
|
|
9
10
|
import useTranslate from '~hooks/useTranslate/useTranslate';
|
|
10
11
|
|
|
@@ -2,9 +2,10 @@ import React from "react";
|
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import { FaArrowRight } from "@react-icons/all-files/fa/FaArrowRight";
|
|
4
4
|
import keygen from "~helpers/keygen";
|
|
5
|
-
import LazyImage from "
|
|
5
|
+
import LazyImage from "~hooks/lazy-image";
|
|
6
6
|
import Button from "../../../../atoms/button/button";
|
|
7
|
-
import {
|
|
7
|
+
import { imagePrettyUrl } from "~helpers/getters.mjs";
|
|
8
|
+
import { getAltText } from '~helpers/image';
|
|
8
9
|
import useTranslate from "~hooks/useTranslate/useTranslate";
|
|
9
10
|
import styles from "./template-one.module.scss";
|
|
10
11
|
|
|
@@ -5,13 +5,13 @@ import PropTypes from "prop-types";
|
|
|
5
5
|
import { FaArrowRight } from "@react-icons/all-files/fa/FaArrowRight";
|
|
6
6
|
import { FaPlus } from "@react-icons/all-files/fa/FaPlus";
|
|
7
7
|
import { FaMinus } from "@react-icons/all-files/fa/FaMinus";
|
|
8
|
-
import LazyImage from "
|
|
8
|
+
import LazyImage from "~hooks/lazy-image";
|
|
9
9
|
import useTranslate from "~hooks/useTranslate/useTranslate";
|
|
10
|
-
import Button from "
|
|
10
|
+
import Button from "~atoms/button/button";
|
|
11
11
|
import {
|
|
12
|
-
getAltText,
|
|
13
12
|
imagePrettyUrl,
|
|
14
|
-
} from "
|
|
13
|
+
} from "~helpers/getters.mjs";
|
|
14
|
+
import { getAltText } from "~helpers/image";
|
|
15
15
|
import styles from "./style.module.scss";
|
|
16
16
|
|
|
17
17
|
export default function TemplateOne({
|
|
@@ -2,10 +2,11 @@ import React from "react";
|
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import { FaArrowRight } from "@react-icons/all-files/fa/FaArrowRight";
|
|
4
4
|
import keygen from "~helpers/keygen";
|
|
5
|
-
import LazyImage from "
|
|
5
|
+
import LazyImage from "~hooks/lazy-image";
|
|
6
6
|
import Button from "../../../../atoms/button/button";
|
|
7
7
|
import useTranslate from "~hooks/useTranslate/useTranslate";
|
|
8
|
-
import {
|
|
8
|
+
import { imagePrettyUrl } from "~helpers/getters.mjs";
|
|
9
|
+
import { getAltText } from '~helpers/image';
|
|
9
10
|
import styles from "./template-two.module.scss";
|
|
10
11
|
|
|
11
12
|
export default function TemplateOne({
|
|
@@ -4,15 +4,16 @@ import React from 'react'
|
|
|
4
4
|
import PropTypes from 'prop-types'
|
|
5
5
|
import Bonus from '~molecules/bonus-box/template-one'
|
|
6
6
|
import SellingPoints from '~atoms/selling-points'
|
|
7
|
-
import ReviewLink from '
|
|
7
|
+
import ReviewLink from '~atoms/review-link'
|
|
8
8
|
import PrettyLink from '~atoms/pretty-link'
|
|
9
9
|
import OperatorCta from '~atoms/button/operator-cta'
|
|
10
|
-
import {
|
|
10
|
+
import { getAltText } from '~helpers/image';
|
|
11
|
+
import { imagePrettyUrl } from '~helpers/getters'
|
|
11
12
|
import LazyImage from '~hooks/lazy-image'
|
|
12
13
|
import { TrackingKeys } from '~constants/tracking-api'
|
|
13
14
|
|
|
14
15
|
import styles from './default-row.module.scss'
|
|
15
|
-
import Ribbons from '
|
|
16
|
+
import Ribbons from '~atoms/ribbons'
|
|
16
17
|
|
|
17
18
|
const Row = ({
|
|
18
19
|
item,
|
|
@@ -2,7 +2,8 @@ import React from "react";
|
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import LazyImage from "~hooks/lazy-image";
|
|
4
4
|
import keygen from "~helpers/keygen";
|
|
5
|
-
import { imagePrettyUrl
|
|
5
|
+
import { imagePrettyUrl } from "~helpers/getters";
|
|
6
|
+
import { getAltText } from '~helpers/image';
|
|
6
7
|
import OperatorCta from "~atoms/button/operator-cta";
|
|
7
8
|
import StarRating from "~molecules/star-rating";
|
|
8
9
|
import { TrackingKeys } from '~constants/tracking-api'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function customData() {}
|
|
@@ -1,76 +1,40 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { render, cleanup, waitFor } from
|
|
3
|
-
import
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, cleanup, waitFor } from "@testing-library/react";
|
|
3
|
+
import "@testing-library/jest-dom/extend-expect";
|
|
4
4
|
|
|
5
|
-
import Head
|
|
5
|
+
import Head from ".";
|
|
6
6
|
|
|
7
|
-
describe(
|
|
8
|
-
test(
|
|
9
|
-
expect(getLanguage('str')).toEqual('str');
|
|
10
|
-
expect(getLanguage('')).toEqual('en');
|
|
11
|
-
expect(getLanguage('no')).toEqual('nb-NO');
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('getCanonicalUrl()', () => {
|
|
15
|
-
expect(getCanonicalUrl({ path: '/' })).toEqual(process.env.GATSBY_SITE_URL);
|
|
16
|
-
expect(getCanonicalUrl({ path: 'sdsdasdsajkdhjkashk' })).toEqual(
|
|
17
|
-
`${process.env.GATSBY_SITE_URL}sdsdasdsajkdhjkashk`
|
|
18
|
-
);
|
|
19
|
-
expect(getCanonicalUrl({ path: 'about', canonical_url: 'contact' })).toEqual(
|
|
20
|
-
`${process.env.GATSBY_SITE_URL}contact`
|
|
21
|
-
);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('getRobotOptions()', () => {
|
|
25
|
-
const arrOne = {
|
|
26
|
-
page_index: 0,
|
|
27
|
-
links_followed: 0,
|
|
28
|
-
images_index: 0,
|
|
29
|
-
show_snippet: 0,
|
|
30
|
-
};
|
|
31
|
-
expect(getRobotOptions(arrOne)).toEqual('noindex,nofollow,noimageindex,nosnippet');
|
|
32
|
-
arrOne.page_index = 1;
|
|
33
|
-
arrOne.show_snippet = 1;
|
|
34
|
-
expect(getRobotOptions(arrOne)).toEqual('nofollow,noimageindex');
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('render with props', async () => {
|
|
7
|
+
describe("Head Component", () => {
|
|
8
|
+
test("render with props", async () => {
|
|
38
9
|
const { container } = render(
|
|
39
10
|
<Head
|
|
40
11
|
siteInfo={{
|
|
41
|
-
site_name:
|
|
42
|
-
site_logo:
|
|
12
|
+
site_name: "test",
|
|
13
|
+
site_logo: "#",
|
|
43
14
|
}}
|
|
44
15
|
page={{
|
|
45
|
-
meta_title:
|
|
46
|
-
language:
|
|
47
|
-
meta_description:
|
|
48
|
-
meta_robots: [
|
|
49
|
-
path:
|
|
50
|
-
preconnect_links: [
|
|
16
|
+
meta_title: "my meta title",
|
|
17
|
+
language: "en",
|
|
18
|
+
meta_description: "my meta description",
|
|
19
|
+
meta_robots: ["one", "two", "three"],
|
|
20
|
+
path: "my path",
|
|
21
|
+
preconnect_links: ["1", "2", "3"],
|
|
51
22
|
seo_json_schema: [],
|
|
52
23
|
sections: { main: {} },
|
|
24
|
+
robot_options: { page_index: 1 },
|
|
53
25
|
}}
|
|
54
26
|
/>
|
|
55
27
|
);
|
|
28
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
56
29
|
expect(container).toBeTruthy();
|
|
57
30
|
await waitFor(() => {
|
|
58
|
-
expect(document.title).toEqual(
|
|
31
|
+
expect(document.title).toEqual("my meta title");
|
|
59
32
|
// expect(document.documentElement.lang).toEqual('en');
|
|
60
|
-
expect(document.querySelectorAll(
|
|
61
|
-
expect(
|
|
62
|
-
|
|
63
|
-
);
|
|
64
|
-
expect(document.getElementsByTagName('meta')[1].getAttribute('content')).toEqual(
|
|
65
|
-
'one,two,three'
|
|
66
|
-
);
|
|
33
|
+
expect(document.querySelectorAll("link[rel=preconnect]")).toHaveLength(3);
|
|
34
|
+
expect(
|
|
35
|
+
document.getElementsByTagName("meta")[0].getAttribute("content")
|
|
36
|
+
).toEqual("my meta description");
|
|
67
37
|
|
|
68
|
-
expect(document.querySelector("meta[name='og:title']").getAttribute('content')).toEqual(
|
|
69
|
-
'my meta title'
|
|
70
|
-
);
|
|
71
|
-
// expect(document.querySelector('meta[name=og:site_name]').getAttribute('content')).toEqual(
|
|
72
|
-
// 'test'
|
|
73
|
-
// );
|
|
74
38
|
});
|
|
75
39
|
});
|
|
76
40
|
});
|
|
@@ -1,95 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import { schemaGenerator } from
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (process.env.GATSBY_SITE_LANG) return process.env.GATSBY_SITE_LANG;
|
|
10
|
-
if (language === 'no') return 'nb-NO';
|
|
11
|
-
return language || 'en';
|
|
12
|
-
}
|
|
13
|
-
export function getCanonicalUrl(page, isTracker) {
|
|
14
|
-
if (page.canonical_url) {
|
|
15
|
-
return `${process.env.GATSBY_SITE_URL}${page.canonical_url}`;
|
|
16
|
-
}
|
|
17
|
-
if (page.path === '/') {
|
|
18
|
-
return process.env.GATSBY_SITE_URL;
|
|
19
|
-
}
|
|
20
|
-
const trailingSlash = process.env.TRAILING_SLASH ? '/' : '';
|
|
21
|
-
|
|
22
|
-
return `${process.env.GATSBY_SITE_URL}${page.path.replace(/^\//, '')}${
|
|
23
|
-
!isTracker ? trailingSlash : ''
|
|
24
|
-
}`
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
export function getRobotOptions(options) {
|
|
28
|
-
const array = [];
|
|
29
|
-
if (!options.page_index && process.env.GATSBY_ACTIVE_ENV !== 'development') array.push('noindex');
|
|
30
|
-
if (!options.links_followed && process.env.GATSBY_ACTIVE_ENV !== 'development')
|
|
31
|
-
array.push('nofollow');
|
|
32
|
-
if (!options.images_index && process.env.GATSBY_ACTIVE_ENV !== 'development')
|
|
33
|
-
array.push('noimageindex');
|
|
34
|
-
if (!options.show_snippet && process.env.GATSBY_ACTIVE_ENV !== 'development')
|
|
35
|
-
array.push('nosnippet');
|
|
36
|
-
if (process.env.GATSBY_ACTIVE_ENV === 'development') array.push('noindex,follow');
|
|
37
|
-
return array.join();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function setName(string) {
|
|
41
|
-
const [name] = string.split('.');
|
|
42
|
-
return name[0].toUpperCase() + name.slice(1);
|
|
43
|
-
}
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
import React from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { schemaGenerator } from "~helpers/schema";
|
|
5
|
+
import keygen from "~helpers/keygen";
|
|
6
|
+
import { getUrl, getLanguage } from "~helpers/getters";
|
|
7
|
+
import { getMetaTags, getCanonicalUrl } from "~helpers/head";
|
|
8
|
+
import customData from "./customData";
|
|
44
9
|
|
|
45
10
|
const HeadData = ({ page = {}, siteInfo }) => {
|
|
46
|
-
const
|
|
47
|
-
const
|
|
11
|
+
const isTracker = page.template === "tracker";
|
|
12
|
+
const metaTags = getMetaTags(page, siteInfo, isTracker);
|
|
48
13
|
let defaultHref = null;
|
|
49
|
-
|
|
14
|
+
|
|
50
15
|
return (
|
|
51
16
|
<>
|
|
52
17
|
<title>{page.meta_title}</title>
|
|
53
18
|
<html lang={getLanguage(page.language)} />
|
|
54
|
-
|
|
55
|
-
{page
|
|
56
|
-
|
|
57
|
-
)}
|
|
58
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
59
|
-
|
|
60
|
-
{page.robot_options && <meta name="robots" content={getRobotOptions(page.robot_options)} />}
|
|
61
|
-
|
|
62
|
-
{process.env.GATSBY_ACTIVE_ENV === 'development' && (
|
|
19
|
+
{metaTags}
|
|
20
|
+
{customData(page)}
|
|
21
|
+
{process.env.GATSBY_ACTIVE_ENV === "development" && (
|
|
63
22
|
<meta name="googlebot" content="noindex,follow" />
|
|
64
23
|
)}
|
|
65
|
-
<link rel="canonical" href={getCanonicalUrl(page, isTracker)}
|
|
66
|
-
{page?.hreflangs?.map((link) => {
|
|
67
|
-
if (link?.default)
|
|
68
|
-
|
|
24
|
+
<link rel="canonical" href={getCanonicalUrl(page, isTracker)} />\
|
|
25
|
+
{page?.hreflangs?.map((link) => {
|
|
26
|
+
if (link?.default) {
|
|
27
|
+
defaultHref = link?.path;
|
|
28
|
+
}
|
|
29
|
+
return (
|
|
30
|
+
<link
|
|
31
|
+
key={keygen()}
|
|
32
|
+
rel="alternate"
|
|
33
|
+
href={getUrl(link.path)}
|
|
34
|
+
hrefLang={link.language}
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
69
37
|
})}
|
|
70
|
-
{defaultHref &&
|
|
71
|
-
|
|
72
|
-
{page.preconnect_links &&
|
|
73
|
-
page.preconnect_links.map((link) => <link key={keygen()} rel="preconnect" href={link} />)}
|
|
74
|
-
<meta name="og:title" content={page.meta_title} />
|
|
75
|
-
<meta name="og:site_name" content={siteInfo?.site_name && setName(siteInfo?.site_name)} />
|
|
76
|
-
<meta name="og:description" content={page.meta_description} />
|
|
77
|
-
<meta name="og:type" content={page.path === '/' ? 'website' : 'article'} />
|
|
78
|
-
<meta name="og:image" content={pageImage} />
|
|
79
|
-
<meta name="og:url" content={getCanonicalUrl(page, isTracker)} />
|
|
80
|
-
<meta
|
|
81
|
-
property="og:locale"
|
|
82
|
-
content={getLanguage(page.language) === 'en' ? 'en_GB' : getLanguage(page.language)}
|
|
83
|
-
/>
|
|
84
|
-
|
|
85
|
-
{schemaGenerator(page, pageImage).map(
|
|
86
|
-
(schema) =>
|
|
87
|
-
schema && (
|
|
88
|
-
<script key={keygen()} type="application/ld+json">
|
|
89
|
-
{`${schema}`}
|
|
90
|
-
</script>
|
|
91
|
-
)
|
|
38
|
+
{defaultHref && (
|
|
39
|
+
<link rel="alternate" href={getUrl(defaultHref)} hrefLang="x-default" />
|
|
92
40
|
)}
|
|
41
|
+
{page.preconnect_links &&
|
|
42
|
+
page.preconnect_links.map((link) => (
|
|
43
|
+
<link key={keygen()} rel="preconnect" href={link} />
|
|
44
|
+
))}
|
|
45
|
+
{schemaGenerator(page, getUrl(page.path)).map((schema) => (
|
|
46
|
+
<script key={keygen()} type="application/ld+json">
|
|
47
|
+
{`${schema}`}
|
|
48
|
+
</script>
|
|
49
|
+
))}
|
|
93
50
|
</>
|
|
94
51
|
);
|
|
95
52
|
};
|
|
@@ -6,7 +6,8 @@ import React, { useEffect } from 'react';
|
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import Button from '~atoms/button/button';
|
|
8
8
|
import LazyImage from '~hooks/lazy-image';
|
|
9
|
-
import { imagePrettyUrl,
|
|
9
|
+
import { imagePrettyUrl, getExtraField } from '~helpers/getters';
|
|
10
|
+
import { getAltText } from '~helpers/image';
|
|
10
11
|
import styles from './tracker.module.scss';
|
|
11
12
|
import { getTrackerName } from '~helpers/tracker';
|
|
12
13
|
import useTranslate from '~hooks/useTranslate/useTranslate';
|
|
@@ -4,7 +4,8 @@ import React, { useEffect } from "react";
|
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import Button from "~atoms/button/button";
|
|
6
6
|
import LazyImage from "~hooks/lazy-image";
|
|
7
|
-
import { imagePrettyUrl,
|
|
7
|
+
import { imagePrettyUrl, getExtraField } from "~helpers/getters";
|
|
8
|
+
import { getAltText } from '~helpers/image';
|
|
8
9
|
import styles from "./tracker.module.scss";
|
|
9
10
|
import { getTrackerName } from "~helpers/tracker";
|
|
10
11
|
import useTranslate from "~hooks/useTranslate/useTranslate";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getLanguage,setName } from '~helpers/getters';
|
|
2
|
+
import { getRobotOptions, getCanonicalUrl } from '~helpers/head';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export default (page, siteInfo, pageImage, isTracker) => [
|
|
6
|
+
{ type: "meta", name: "description", content: page.meta_description },
|
|
7
|
+
{ type: "meta", name: "robots", content: getRobotOptions(page.robot_options) },
|
|
8
|
+
{ type: "meta", property: "og:title", content: page.meta_title },
|
|
9
|
+
{ type: "meta", property: "og:site_name", content: siteInfo?.site_name ? setName(siteInfo.site_name) : "" },
|
|
10
|
+
{ type: "meta", property: "og:description", content: page.meta_description },
|
|
11
|
+
{ type: "meta", property: "og:type", content: page.path === '/' ? 'website' : 'article' },
|
|
12
|
+
{ type: "meta", property: "og:image", content: pageImage },
|
|
13
|
+
{ type: "meta", property: "og:url", content: getCanonicalUrl(page, isTracker) },
|
|
14
|
+
{ type: "meta", property: "og:locale", content: getLanguage(page.language) === 'en' ? 'en_GB' : getLanguage(page.language) },
|
|
15
|
+
];
|
|
@@ -127,7 +127,8 @@ export const pickRelationKeys = {
|
|
|
127
127
|
'languages',
|
|
128
128
|
'average_deposit_fee_amount',
|
|
129
129
|
'average_withdrawal_times',
|
|
130
|
-
'best_game'
|
|
130
|
+
'best_game',
|
|
131
|
+
'rating_comments',
|
|
131
132
|
],
|
|
132
133
|
operator_simplified: [
|
|
133
134
|
"short_name",
|
|
@@ -140,7 +141,7 @@ export const pickRelationKeys = {
|
|
|
140
141
|
"logo",
|
|
141
142
|
"type",
|
|
142
143
|
"market",
|
|
143
|
-
"status"
|
|
144
|
+
"status",
|
|
144
145
|
],
|
|
145
146
|
game: [
|
|
146
147
|
"id",
|
package/src/helpers/getters.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
1
2
|
/* eslint-disable no-prototype-builtins */
|
|
2
3
|
/* eslint-disable no-nested-ternary */
|
|
3
4
|
import { generateTrackerLink } from "./generators.mjs";
|
|
@@ -106,15 +107,6 @@ export function image(filename, width, height, fit = "cover") {
|
|
|
106
107
|
return `${cloudFrontUrl}/${Buffer.from(imageRequest).toString("base64")}`;
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
export function getImageFilename(src) {
|
|
110
|
-
const srcArr = src && src.substring(src.lastIndexOf("/") + 1).split(".");
|
|
111
|
-
if (!srcArr.length) {
|
|
112
|
-
return "";
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return srcArr[0];
|
|
116
|
-
}
|
|
117
|
-
|
|
118
110
|
export function getImageExtension(filename) {
|
|
119
111
|
return filename && filename.split(".").pop();
|
|
120
112
|
}
|
|
@@ -363,10 +355,11 @@ export function getUrl(path) {
|
|
|
363
355
|
return process.env.GATSBY_SITE_URL;
|
|
364
356
|
}
|
|
365
357
|
|
|
366
|
-
return `${process.env.GATSBY_SITE_URL}${path.replace(/^\//, "")}`;
|
|
358
|
+
return `${process.env.GATSBY_SITE_URL}${path.replace(/^\//, "")}${process.env.TRALING_SLASH ? "/" : ""}`;
|
|
367
359
|
}
|
|
368
360
|
|
|
369
361
|
export function getLanguage(language) {
|
|
362
|
+
if (process.env.GATSBY_SITE_LANG) return process.env.GATSBY_SITE_LANG;
|
|
370
363
|
if (language === "no") return "nb-NO";
|
|
371
364
|
return language || "en";
|
|
372
365
|
}
|
|
@@ -446,10 +439,6 @@ export const getRoundMinutes = (time) => {
|
|
|
446
439
|
return value === 0 ? 1 : value;
|
|
447
440
|
};
|
|
448
441
|
|
|
449
|
-
export function getAltText(imageObject, defaultAlt = "") {
|
|
450
|
-
return imageObject && imageObject.alt ? imageObject.alt : defaultAlt;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
442
|
export function updateArrayTranslations(array, keysArray, translations) {
|
|
454
443
|
if (array && array.length > 0 && keysArray && keysArray.length > 0) {
|
|
455
444
|
array.forEach((elm, index) => {
|
|
@@ -534,6 +523,11 @@ export const filterNonNullValues = (data) =>
|
|
|
534
523
|
return acc;
|
|
535
524
|
}, {});
|
|
536
525
|
|
|
526
|
+
|
|
527
|
+
export function setName(string) {
|
|
528
|
+
const [name] = string.split(".");
|
|
529
|
+
return name[0].toUpperCase() + name.slice(1);
|
|
530
|
+
}
|
|
537
531
|
export const trailingSlash = (content) => {
|
|
538
532
|
if (!content || process.env.TRAILING_SLASH !== "true") return content;
|
|
539
533
|
|
|
@@ -313,16 +313,6 @@ describe('Getters Helper', () => {
|
|
|
313
313
|
expect(Getters.getRoundMinutes('3:29')).toBe(3);
|
|
314
314
|
});
|
|
315
315
|
|
|
316
|
-
test('Test altText', () => {
|
|
317
|
-
const alt = Getters.getAltText({ alt: 'imageAlt' }, 'default');
|
|
318
|
-
expect(alt).toEqual('imageAlt');
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
test('Test without altText', () => {
|
|
322
|
-
const altText = Getters.getAltText(null, 'default');
|
|
323
|
-
expect(altText).toEqual('default');
|
|
324
|
-
});
|
|
325
|
-
|
|
326
316
|
const array = ['apple', 'banana', 'cherry'];
|
|
327
317
|
const keysArray = ['fruit_apple', 'fruit_banana', 'fruit_cherry'];
|
|
328
318
|
const translations = {
|
|
@@ -457,6 +447,36 @@ describe('Getters Helper', () => {
|
|
|
457
447
|
const expected = { a: 1, c: 2 };
|
|
458
448
|
expect(Getters.filterNonNullValues(input)).toEqual(expected);
|
|
459
449
|
});
|
|
450
|
+
|
|
451
|
+
describe('getLanguage', () => {
|
|
452
|
+
it('returns GATSBY_SITE_LANG if set', () => {
|
|
453
|
+
process.env.GATSBY_SITE_LANG = 'fr';
|
|
454
|
+
expect(Getters.getLanguage('en')).toBe('fr');
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
it('returns "nb-NO" if language is "no"', () => {
|
|
458
|
+
delete process.env.GATSBY_SITE_LANG;
|
|
459
|
+
expect(Getters.getLanguage('no')).toBe('nb-NO');
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
it('returns provided language if GATSBY_SITE_LANG is not set', () => {
|
|
463
|
+
delete process.env.GATSBY_SITE_LANG;
|
|
464
|
+
expect(Getters.getLanguage('es')).toBe('es');
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
it('returns "en" if no language is provided', () => {
|
|
468
|
+
delete process.env.GATSBY_SITE_LANG;
|
|
469
|
+
expect(Getters.getLanguage()).toBe('en');
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
describe('setName', () => {
|
|
474
|
+
it('returns capitalized name from string', () => {
|
|
475
|
+
expect(Getters.setName('example.com')).toBe('Example');
|
|
476
|
+
});
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
|
|
460
480
|
test('basic functionality with sample HTML', () => {
|
|
461
481
|
process.env.TRAILING_SLASH = 'true';
|
|
462
482
|
process.env.GATSBY_SITE_URL = 'https://demo-gatsby-theme.gigmedia.com/';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { getPageImage, imagePrettyUrl } from "~helpers/getters";
|
|
3
|
+
import keygen from "~helpers/keygen";
|
|
4
|
+
import metaTags from "~constants/metaTags";
|
|
5
|
+
|
|
6
|
+
export const getMetaTags = (page, siteInfo, isTracker) => {
|
|
7
|
+
const pageImage = getPageImage(page) || imagePrettyUrl(siteInfo?.site_logo);
|
|
8
|
+
return metaTags(page, siteInfo, pageImage, isTracker).map((meta) => (
|
|
9
|
+
<meta
|
|
10
|
+
key={keygen()}
|
|
11
|
+
{...(meta.name ? { name: meta.name } : { property: meta.property })}
|
|
12
|
+
content={meta.content}
|
|
13
|
+
/>
|
|
14
|
+
));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function getCanonicalUrl(page, isTracker) {
|
|
18
|
+
if (page.canonical_url) {
|
|
19
|
+
return `${process.env.GATSBY_SITE_URL}${page.canonical_url}`;
|
|
20
|
+
}
|
|
21
|
+
if (page.path === "/") {
|
|
22
|
+
return process.env.GATSBY_SITE_URL;
|
|
23
|
+
}
|
|
24
|
+
const trailingSlash = process.env.TRAILING_SLASH ? "/" : "";
|
|
25
|
+
|
|
26
|
+
return `${process.env.GATSBY_SITE_URL}${page.path.replace(/^\//, "")}${
|
|
27
|
+
!isTracker ? trailingSlash : ""
|
|
28
|
+
}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function getRobotOptions(options) {
|
|
32
|
+
const array = [];
|
|
33
|
+
if (
|
|
34
|
+
!options &&
|
|
35
|
+
!options.page_index &&
|
|
36
|
+
process.env.GATSBY_ACTIVE_ENV !== "development"
|
|
37
|
+
)
|
|
38
|
+
array.push("noindex");
|
|
39
|
+
if (
|
|
40
|
+
!options.links_followed &&
|
|
41
|
+
process.env.GATSBY_ACTIVE_ENV !== "development"
|
|
42
|
+
)
|
|
43
|
+
array.push("nofollow");
|
|
44
|
+
if (!options.images_index && process.env.GATSBY_ACTIVE_ENV !== "development")
|
|
45
|
+
array.push("noimageindex");
|
|
46
|
+
if (!options.show_snippet && process.env.GATSBY_ACTIVE_ENV !== "development")
|
|
47
|
+
array.push("nosnippet");
|
|
48
|
+
if (process.env.GATSBY_ACTIVE_ENV === "development")
|
|
49
|
+
array.push("noindex,follow");
|
|
50
|
+
return array.join();
|
|
51
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {getMetaTags, getCanonicalUrl} from './head';
|
|
2
|
+
|
|
3
|
+
describe('head.js functions', () => {
|
|
4
|
+
describe('getMetaTags', () => {
|
|
5
|
+
it('returns meta tags correctly', () => {
|
|
6
|
+
const page = {
|
|
7
|
+
robot_options: { page_index: 1 },
|
|
8
|
+
path:"/"
|
|
9
|
+
};
|
|
10
|
+
const siteInfo = { site_logo: 'logo.png' };
|
|
11
|
+
const isTracker = false;
|
|
12
|
+
|
|
13
|
+
const result = getMetaTags(page, siteInfo, isTracker);
|
|
14
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
15
|
+
expect(result).toBeTruthy();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe('getCanonicalUrl', () => {
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
process.env.GATSBY_SITE_URL = 'https://example.com';
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('returns canonical_url if set', () => {
|
|
25
|
+
const page = { canonical_url: 'canonical' };
|
|
26
|
+
process.env.GATSBY_SITE_URL = 'https://example.com/';
|
|
27
|
+
expect(getCanonicalUrl(page, false)).toBe('https://example.com/canonical');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('returns site URL if page path is "/"', () => {
|
|
31
|
+
const page = { path: '/' };
|
|
32
|
+
process.env.GATSBY_SITE_URL = 'https://example.com/';
|
|
33
|
+
expect(getCanonicalUrl(page, false)).toBe('https://example.com/');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('returns URL with trailing slash if TRAILING_SLASH is set', () => {
|
|
37
|
+
process.env.TRAILING_SLASH = 'true';
|
|
38
|
+
process.env.GATSBY_SITE_URL = 'https://example.com/';
|
|
39
|
+
const page = { path: 'about' };
|
|
40
|
+
expect(getCanonicalUrl(page, false)).toBe('https://example.com/about/');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('returns URL without trailing slash if TRAILING_SLASH is not set', () => {
|
|
44
|
+
delete process.env.TRAILING_SLASH;
|
|
45
|
+
process.env.GATSBY_SITE_URL = 'https://example.com/';
|
|
46
|
+
const page = { path: 'about' };
|
|
47
|
+
expect(getCanonicalUrl(page, false)).toBe('https://example.com/about');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
|
+
/* eslint-disable import/prefer-default-export */
|
|
3
|
+
import useTranslate from '../hooks/useTranslate/useTranslate';
|
|
4
|
+
|
|
5
|
+
export function getAltText(imageObject, defaultAlt = "") {
|
|
6
|
+
// If alt is for operator image we check for custom translations
|
|
7
|
+
if(imageObject && imageObject.alt && imageObject.alt.toLowerCase().includes('image for')) {
|
|
8
|
+
const originalAlt = imageObject.alt.toLowerCase();
|
|
9
|
+
const regex = /(logo image for|image for)\s*/i;
|
|
10
|
+
|
|
11
|
+
// Replace all occurrences of the matched phrases with an empty string
|
|
12
|
+
const newAlt = `${useTranslate('image_for', 'Logo image for')} ${originalAlt.replace(regex, '')}`;
|
|
13
|
+
return useTranslate(newAlt.replace(/\s+/g, '_').toLowerCase(), newAlt);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return imageObject && imageObject.alt ? imageObject.alt : defaultAlt;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getImageFilename(src) {
|
|
20
|
+
const srcArr = src && src.substring(src.lastIndexOf("/") + 1).split(".");
|
|
21
|
+
if (!srcArr.length) {
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return srcArr[0];
|
|
26
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as Image from './image';
|
|
2
|
+
|
|
3
|
+
describe('Getters Helper', () => {
|
|
4
|
+
|
|
5
|
+
test('Test altText', () => {
|
|
6
|
+
const alt = Image.getAltText({ alt: 'imageAlt' }, 'default');
|
|
7
|
+
expect(alt).toEqual('imageAlt');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('Test without altText', () => {
|
|
11
|
+
const altText = Image.getAltText(null, 'default');
|
|
12
|
+
expect(altText).toEqual('default');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
test('Test with altText for operators', () => {
|
|
18
|
+
const altText = Image.getAltText({ alt: 'Image for operator' }, 'Test');
|
|
19
|
+
expect(altText).toEqual('Logo image for operator');
|
|
20
|
+
});
|
|
21
|
+
});
|
package/src/helpers/schema.js
CHANGED
|
@@ -109,6 +109,9 @@ export const prosAndConsData = (pageObj) => {
|
|
|
109
109
|
const prosAndConstObj =
|
|
110
110
|
pageObj?.sections?.main?.modules?.find((elm) => elm?.name === 'pros_and_cons') || {};
|
|
111
111
|
|
|
112
|
+
const anchroUrl = prosAndConstObj?.anchored ? prosAndConstObj?.anchor_slug : '';
|
|
113
|
+
|
|
114
|
+
|
|
112
115
|
// There are url keys because it is required
|
|
113
116
|
// otherwise it would throw errors
|
|
114
117
|
return (
|
|
@@ -120,8 +123,8 @@ export const prosAndConsData = (pageObj) => {
|
|
|
120
123
|
prosAndConstObj?.pros?.map((elm, index) => ({
|
|
121
124
|
'@type': 'ListItem',
|
|
122
125
|
position: index + 1,
|
|
123
|
-
url: `${getUrl('/')}#${elm}`,
|
|
124
126
|
name: elm,
|
|
127
|
+
url: `${getUrl('/')}${anchroUrl ? `#${anchroUrl}` : ''}`
|
|
125
128
|
})) || [],
|
|
126
129
|
},
|
|
127
130
|
}),
|
|
@@ -132,7 +135,7 @@ export const prosAndConsData = (pageObj) => {
|
|
|
132
135
|
prosAndConstObj?.cons?.map((elm, index) => ({
|
|
133
136
|
'@type': 'ListItem',
|
|
134
137
|
position: index + 1,
|
|
135
|
-
url: `${getUrl('/')}
|
|
138
|
+
url: `${getUrl('/')}${anchroUrl ? `#${anchroUrl}` : ''}`,
|
|
136
139
|
name: elm,
|
|
137
140
|
})) || [],
|
|
138
141
|
},
|
|
@@ -422,7 +425,7 @@ export function templateSchemas(page, pageImage) {
|
|
|
422
425
|
|
|
423
426
|
return JSON.stringify(generateSchemaObject(schema));
|
|
424
427
|
}
|
|
425
|
-
case 'operator': {
|
|
428
|
+
case 'operator': {
|
|
426
429
|
const schema = {
|
|
427
430
|
'@context': 'https://schema.org',
|
|
428
431
|
'@type': 'Review',
|
|
@@ -434,7 +437,7 @@ export function templateSchemas(page, pageImage) {
|
|
|
434
437
|
'@type': 'Organization',
|
|
435
438
|
url: getUrl(page.path),
|
|
436
439
|
name: page.title || '',
|
|
437
|
-
image: page.relation?.logo?.filename,
|
|
440
|
+
image: imagePrettyUrl(page.relation?.logo?.filename),
|
|
438
441
|
},
|
|
439
442
|
reviewRating: {
|
|
440
443
|
'@type': 'Rating',
|
|
@@ -466,7 +466,7 @@ describe('Schema Helper', () => {
|
|
|
466
466
|
expect(json.itemReviewed['@type']).toEqual('Organization');
|
|
467
467
|
expect(json.itemReviewed.url).toEqual(getUrl('operator_page'));
|
|
468
468
|
expect(json.itemReviewed.name).toEqual('Operator Title');
|
|
469
|
-
expect(json.itemReviewed.image).toEqual('logo_url/image.jpg');
|
|
469
|
+
expect(json.itemReviewed.image).toEqual('https://cdn.images.com/logo_url/image.jpg');
|
|
470
470
|
|
|
471
471
|
expect(Object.prototype.toString.call(json.reviewRating)).toEqual('[object Object]');
|
|
472
472
|
expect(json.reviewRating['@type']).toEqual('Rating');
|