gatsby-matrix-theme 7.2.2 → 7.2.3

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 CHANGED
@@ -1,3 +1,14 @@
1
+ ## [7.2.3](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/compare/v7.2.2...v7.2.3) (2022-10-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * core version ([9159d5f](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/9159d5f477acbab05397fa94535d630b9e525b83))
7
+ * old schema matrix ([3f7040e](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/3f7040ee0d6c29c2a54af820c6232c4d5ff54688))
8
+
9
+
10
+ * Merge branch 'tm-2833-old-schema-matrix' into 'master' ([6b5f5ea](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/commit/6b5f5ea58fc2222cf977ba3ae47018b72cc3e451))
11
+
1
12
  ## [7.2.2](https://git.ilcd.rocks/team-floyd/themes/matrix-theme/compare/v7.2.1...v7.2.2) (2022-10-10)
2
13
 
3
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-matrix-theme",
3
- "version": "7.2.2",
3
+ "version": "7.2.3",
4
4
  "main": "index.js",
5
5
  "description": "Matrix Theme NPM Package",
6
6
  "author": "",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "gatsby": "^4.20.0",
27
- "gatsby-core-theme": "12.0.3",
27
+ "gatsby-core-theme": "12.0.4",
28
28
  "gatsby-plugin-sharp": "^4.10.2",
29
29
  "gatsby-plugin-sitemap": "^3.3.0",
30
30
  "gatsby-transformer-sharp": "^4.10.0",
@@ -0,0 +1,165 @@
1
+ import { getUrl } from 'gatsby-core-theme/src/helpers/getters';
2
+ import * as Schema from './schema';
3
+
4
+ const parseCheckSchema = (schema) => {
5
+ const json = JSON.parse(schema);
6
+ expect(Object.prototype.toString.call(schema)).toEqual('[object String]');
7
+ expect(Object.prototype.toString.call(json)).toEqual('[object Object]');
8
+ expect(json['@context']).toEqual('https://schema.org');
9
+ return json;
10
+ };
11
+
12
+ describe('Schema Helper', () => {
13
+ test('breadcrumbsSchema()', () => {
14
+ const output = Schema.breadcrumbsSchema({
15
+ path: 'some_path',
16
+ title: 'Some Title Review',
17
+ breadcrumbs: [
18
+ { path: 'breadcrumb_a', label: 'Breadcrumb A' },
19
+ { path: 'breadcrumb_b', label: 'Breadcrumb B' },
20
+ ],
21
+ siteSchema: {
22
+ site_name: 'Site Name',
23
+ },
24
+ });
25
+
26
+ const json = parseCheckSchema(output);
27
+ expect(json['@type']).toEqual('BreadcrumbList');
28
+
29
+ expect(Object.prototype.toString.call(json.itemListElement)).toEqual('[object Array]');
30
+ expect(json.itemListElement).toHaveLength(4);
31
+ json.itemListElement.forEach((element, i) => {
32
+ expect(Object.prototype.toString.call(element)).toEqual('[object Object]');
33
+ expect(Object.prototype.toString.call(element.item)).toEqual('[object Object]');
34
+ expect(element['@type']).toEqual('ListItem');
35
+ expect(element.position).toEqual(i + 1);
36
+ switch (i) {
37
+ case 1:
38
+ expect(element.name).toEqual('Breadcrumb A');
39
+ expect(element.item['@type']).toEqual('Thing');
40
+ expect(element.item['@id']).toEqual(getUrl('breadcrumb_a'));
41
+ expect(element.item.url).toEqual(getUrl('breadcrumb_a'));
42
+ break;
43
+ case 2:
44
+ expect(element.name).toEqual('Breadcrumb B');
45
+ expect(element.item['@type']).toEqual('Thing');
46
+ expect(element.item['@id']).toEqual(getUrl('breadcrumb_b'));
47
+ expect(element.item.url).toEqual(getUrl('breadcrumb_b'));
48
+ break;
49
+ case 3:
50
+ expect(element.name).toEqual('Some Title Review');
51
+ expect(element.item['@type']).toEqual('Thing');
52
+ expect(element.item['@id']).toEqual(getUrl('some_path'));
53
+ expect(element.item.url).toEqual(getUrl('some_path'));
54
+ break;
55
+ default:
56
+ expect(element.name).toEqual('Site Name');
57
+ expect(element.item['@type']).toEqual('Thing');
58
+ expect(element.item['@id']).toEqual(getUrl('/'));
59
+ expect(element.item.url).toEqual(getUrl('/'));
60
+ break;
61
+ }
62
+ });
63
+ });
64
+
65
+ test('schemaGenerator(PCSA)', () => {
66
+ process.env.GATSBY_SITE_NAME = 'playcasino.co.za';
67
+ const output = Schema.schemaGenerator({
68
+ seo_json_schema: 'SEO JSON Schema',
69
+ breadcrumbs: [{ path: '/' }],
70
+ type: 'operator',
71
+ path: '/',
72
+ sections: { main: { modules: [{ name: 'faq' }] } },
73
+ siteSchema: {
74
+ site_name: 'Site Name',
75
+ },
76
+ });
77
+
78
+ expect(Object.prototype.toString.call(output)).toEqual('[object Array]');
79
+
80
+ expect(Object.prototype.toString.call(output[0])).toEqual('[object String]');
81
+ expect(output[0]).toEqual('SEO JSON Schema');
82
+
83
+ const jsonBreadcrumbs = parseCheckSchema(output[1]);
84
+ expect(jsonBreadcrumbs['@type']).toEqual('BreadcrumbList');
85
+
86
+ expect(output[2]).toEqual(null);
87
+
88
+ const jsonOrganization = parseCheckSchema(output[3]);
89
+ expect(jsonOrganization['@type']).toEqual('Organization');
90
+
91
+ const jsonArticle = parseCheckSchema(output[4]);
92
+ expect(jsonArticle['@type']).toEqual('Review');
93
+
94
+ const jsonFaq = parseCheckSchema(output[5]);
95
+ expect(jsonFaq['@type']).toEqual('FAQPage');
96
+ });
97
+
98
+ test('schemaGenerator(IL)', () => {
99
+ process.env.GATSBY_SITE_NAME = 'irishluck.ie';
100
+ const output = Schema.schemaGenerator({
101
+ seo_json_schema: 'SEO JSON Schema',
102
+ type: 'article',
103
+ path: '/test-path',
104
+ });
105
+
106
+ expect(Object.prototype.toString.call(output)).toEqual('[object Array]');
107
+
108
+ expect(Object.prototype.toString.call(output[0])).toEqual('[object String]');
109
+ expect(output[0]).toEqual('SEO JSON Schema');
110
+
111
+ expect(output[1]).toEqual(null);
112
+
113
+ const jsonWebpage = parseCheckSchema(output[2]);
114
+ expect(jsonWebpage['@type']).toEqual('WebPage');
115
+ expect(jsonWebpage.keywords).toEqual(undefined);
116
+ expect(jsonWebpage.author.publishingPrinciples).toEqual(undefined);
117
+ expect(jsonWebpage.author.knowsAbout).toEqual(undefined);
118
+
119
+ expect(output[3]).toEqual(null);
120
+
121
+ const jsonArticle = parseCheckSchema(output[4]);
122
+ expect(jsonArticle['@type']).toEqual('Article');
123
+
124
+ expect(output[5]).toEqual(null);
125
+ });
126
+
127
+ test('schemaGenerator(NSA)', () => {
128
+ process.env.GATSBY_SITE_NAME = 'norskespilleautomater.com';
129
+ const output = Schema.schemaGenerator({
130
+ seo_json_schema: 'SEO JSON Schema',
131
+ type: 'other',
132
+ path: '/test-path',
133
+ siteSchema: {
134
+ publishing_principles: 'https://www.norskespilleautomater.com/om-oss/prinsipper',
135
+ },
136
+ });
137
+
138
+ expect(Object.prototype.toString.call(output)).toEqual('[object Array]');
139
+
140
+ expect(Object.prototype.toString.call(output[0])).toEqual('[object String]');
141
+ expect(output[0]).toEqual('SEO JSON Schema');
142
+
143
+ expect(output[1]).toEqual(null);
144
+
145
+ const jsonWebpage = parseCheckSchema(output[2]);
146
+ expect(jsonWebpage['@type']).toEqual('WebPage');
147
+ expect(jsonWebpage.keywords).toEqual(undefined);
148
+ expect(jsonWebpage.author.publishingPrinciples).toEqual(
149
+ 'https://www.norskespilleautomater.com/om-oss/prinsipper'
150
+ );
151
+ expect(Object.prototype.toString.call(jsonWebpage.author.knowsAbout)).toEqual('[object Array]');
152
+ expect(jsonWebpage.author.knowsAbout).toHaveLength(4);
153
+ expect(Object.prototype.toString.call(jsonWebpage.author.knowsAbout[0])).toEqual(
154
+ '[object Object]'
155
+ );
156
+ expect(jsonWebpage.author.knowsAbout[0]['@type']).toEqual('Thing');
157
+ expect(jsonWebpage.author.knowsAbout[0].name).toEqual('Norway');
158
+
159
+ expect(output[3]).toEqual(null);
160
+
161
+ expect(output[4]).toEqual(null);
162
+
163
+ expect(output[5]).toEqual(null);
164
+ });
165
+ });
@@ -0,0 +1,137 @@
1
+ /* eslint-disable import/prefer-default-export */
2
+ import {
3
+ generateSchemaObject,
4
+ webPageSchema,
5
+ organizationSchema,
6
+ moduleSchemas,
7
+ templateSchemas,
8
+ } from 'gatsby-core-theme/src/helpers/schema';
9
+ import { getUrl } from 'gatsby-core-theme/src/helpers/getters';
10
+
11
+ const knowsAbout = [
12
+ {
13
+ '@type': 'Thing',
14
+ name: 'Norway',
15
+ sameAs: [
16
+ 'https://no.wikipedia.org/wiki/Norge',
17
+ 'https://www.google.no/search?q=Norge&pws=0&nord=1&hl=no&gl=NO',
18
+ ],
19
+ },
20
+ {
21
+ '@type': 'Thing',
22
+ name: 'LottStift',
23
+ sameAs: [
24
+ 'https://no.wikipedia.org/wiki/Lotteri-_og_stiftelsestilsynet',
25
+ 'https://www.google.no/search?q=lottstift&pws=0&nord=1&hl=no&gl=NO',
26
+ ],
27
+ },
28
+ {
29
+ '@type': 'Thing',
30
+ name: 'Kasino',
31
+ sameAs: [
32
+ 'https://no.wikipedia.org/wiki/Kasino',
33
+ 'https://www.google.no/search?q=Kasino&pws=0&nord=1&hl=no&gl=NO',
34
+ ],
35
+ },
36
+ {
37
+ '@type': 'Thing',
38
+ name: 'Norsk Tipping Kommisjonær',
39
+ sameAs: [
40
+ 'https://no.wikipedia.org/wiki/Norsk_Tipping',
41
+ 'https://www.google.no/search?q=norsk+tipping&pws=0&nord=1&hl=no&gl=NO',
42
+ ],
43
+ },
44
+ ];
45
+
46
+ export function breadcrumbsSchema({
47
+ // type,
48
+ path,
49
+ title,
50
+ breadcrumbs,
51
+ siteSchema: { site_name: siteName } = {},
52
+ // relation: { game_provider: gameProvider } = {},
53
+ }) {
54
+ /* Disabled until we get a confirmation from NSA Seo */
55
+ // const hasExtra = process.env.GATSBY_SITE_NAME === 'norskespilleautomater.com' && type === 'game';
56
+ const schema = {
57
+ '@context': 'https://schema.org',
58
+ '@type': 'BreadcrumbList',
59
+ '@id': `${getUrl(path)}#breadcrumblist`,
60
+ itemListElement: [
61
+ {
62
+ '@type': 'ListItem',
63
+ name: siteName,
64
+ position: 1,
65
+ item: {
66
+ '@type': 'Thing',
67
+ '@id': getUrl('/'),
68
+ url: getUrl('/'),
69
+ },
70
+ },
71
+ ...breadcrumbs.map((breadcrumb, index) => ({
72
+ '@type': 'ListItem',
73
+ name: breadcrumb.label,
74
+ position: index + 2,
75
+ item: {
76
+ '@type': 'Thing',
77
+ '@id': getUrl(breadcrumb.path),
78
+ url: getUrl(breadcrumb.path),
79
+ },
80
+ })),
81
+ /* Disabled until we get a confirmation from NSA Seo */
82
+ // ...(hasExtra
83
+ // ? [
84
+ // {
85
+ // '@type': 'ListItem',
86
+ // name: gameProvider?.name,
87
+ // position: breadcrumbs.length + 2,
88
+ // item: {
89
+ // '@type': 'Thing',
90
+ // '@id': getUrl(`spilleverandorer/${gameProvider?.short_name}`),
91
+ // url: getUrl(`spilleverandorer/${gameProvider?.short_name}`),
92
+ // },
93
+ // },
94
+ // ]
95
+ // : []),
96
+ {
97
+ '@type': 'ListItem',
98
+ name: title,
99
+ // position: breadcrumbs.length + (hasExtra ? 3 : 2),
100
+ position: breadcrumbs.length + 2,
101
+ item: {
102
+ '@type': 'Thing',
103
+ '@id': getUrl(path),
104
+ url: getUrl(path),
105
+ },
106
+ },
107
+ ],
108
+ };
109
+
110
+ return JSON.stringify(generateSchemaObject(schema));
111
+ }
112
+
113
+ export function schemaGenerator(page = {}, pageImage) {
114
+ const isNSA = process.env.GATSBY_SITE_NAME === 'norskespilleautomater.com';
115
+ if (isNSA) {
116
+ page.knowsAbout = knowsAbout;
117
+ }
118
+
119
+ // Temporary Change for removing webPageSchema
120
+ const hasWebPageSchema = (page.type !== 'operator' && page.type !== 'game') || isNSA;
121
+ const hasOrganisationSchema = page.path === '/' || page.path === 'about-us';
122
+ const jsonSchema = [
123
+ // Page Schema
124
+ page.seo_json_schema,
125
+ // Breadcrumbs Schema
126
+ page.breadcrumbs?.length ? breadcrumbsSchema(page) : null,
127
+ hasWebPageSchema ? webPageSchema(page, pageImage) : null,
128
+ hasOrganisationSchema ? organizationSchema(page, pageImage) : null,
129
+ templateSchemas(page, pageImage),
130
+ // Modules Schemas
131
+ ...(page.sections?.main?.modules
132
+ ? moduleSchemas(page.sections.main.modules, page.path)
133
+ : [null]),
134
+ ];
135
+
136
+ return jsonSchema;
137
+ }