gatsby-core-theme 29.0.2 → 29.0.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 +24 -0
- package/gatsby-node.mjs +1 -2
- package/package.json +1 -1
- package/src/components/atoms/author-box/index.js +29 -13
- package/src/components/atoms/module-title/index.js +2 -2
- package/src/components/molecules/module/index.js +1 -1
- package/src/components/molecules/module/module.test.js +1 -1
- package/src/helpers/schema.js +66 -16
- package/src/helpers/schema.test.js +68 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
## [29.0.3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v29.0.2...v29.0.3) (2023-09-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* search for multiple markets ([39cb250](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/39cb250a1728420d38cba94534e6cea771127f8b))
|
|
7
|
+
* update default title tag ([631f5cd](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/631f5cda840225a534c642117d5837cf6efe66fd))
|
|
8
|
+
* update schema and module ([c74282c](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/c74282c6299e66d5a66516ac3aad9938a7970d92))
|
|
9
|
+
* update schema to include speakable ([95744c9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/95744c9fc11bc7ea7a8de1236150ca421c8b6796))
|
|
10
|
+
* update schema to include speakable ([2b76573](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/2b7657399300cbe7fc469b2088f36991a4d8feaf))
|
|
11
|
+
* update speakable schema ([d11d779](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/d11d779b41cb934fc5305b729d22132a9300d2a9))
|
|
12
|
+
* update speakable schema ([9c0802b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/9c0802bd40eb39adc0a545ea94a33a42d6c16157))
|
|
13
|
+
* update tests ([6b944ca](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/6b944ca93a11379f539bd16455d155409c28d90d))
|
|
14
|
+
* updte tests ([0814735](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/081473596fa535f86be6cbc17ac4f312281481b8))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Code Refactoring
|
|
18
|
+
|
|
19
|
+
* add custom icons for author box ([64f3dcb](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/64f3dcbe4d3a581ad513f317e1a4f551355b1824))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
* Merge branch 'tm-3628-author-box' into 'master' ([b0bc0c3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/b0bc0c3db99826c5d999a3bed8b6ea3382c848a8))
|
|
23
|
+
* Merge branch 'tm-3576-speakable-schema' into 'master' ([19b1194](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/19b1194eb65cb20b83c6a3592b20e4bd8e1cb7a4))
|
|
24
|
+
|
|
1
25
|
## [29.0.2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v29.0.1...v29.0.2) (2023-09-05)
|
|
2
26
|
|
|
3
27
|
|
package/gatsby-node.mjs
CHANGED
|
@@ -445,8 +445,7 @@ export const createPages = async ({ actions: { createPage } }, themeOptions) =>
|
|
|
445
445
|
|
|
446
446
|
export const onCreatePage = ({ page, actions }) => {
|
|
447
447
|
const { createPage, deletePage } = actions;
|
|
448
|
-
|
|
449
|
-
if (page.path.match(/^\/[a-z]{2}\/404\/$/)) {
|
|
448
|
+
if (page.path.match(/^\/[a-z]{2}\/404$/)) {
|
|
450
449
|
const oldPage = { ...page };
|
|
451
450
|
const langCode = page.path.split(`/`)[1];
|
|
452
451
|
page.matchPath = `/${langCode}/*`;
|
package/package.json
CHANGED
|
@@ -26,8 +26,12 @@ export default function AuthorBox({
|
|
|
26
26
|
readingTime = '',
|
|
27
27
|
reviewer = {},
|
|
28
28
|
check = '../../../images/check.svg',
|
|
29
|
-
|
|
29
|
+
verifiedIcon = '../../../images/checkCircle.svg',
|
|
30
|
+
verifiedIconWidth = 20,
|
|
31
|
+
verifiedIconHeight = 20,
|
|
30
32
|
showReadMore = true,
|
|
33
|
+
readTimeIcon = <FaClock />,
|
|
34
|
+
contReadIcon = <FaArrowRight />,
|
|
31
35
|
}) {
|
|
32
36
|
const { translations } = useContext(Context) || {};
|
|
33
37
|
const socialLinks = [
|
|
@@ -61,10 +65,10 @@ export default function AuthorBox({
|
|
|
61
65
|
<p className={styles.name || ''}>
|
|
62
66
|
<span>{author?.name}</span>
|
|
63
67
|
<LazyImage
|
|
64
|
-
src=
|
|
68
|
+
src={verifiedIcon}
|
|
65
69
|
alt={translate(translations, 'verified', 'Verified')}
|
|
66
|
-
width={
|
|
67
|
-
height={
|
|
70
|
+
width={verifiedIconWidth}
|
|
71
|
+
height={verifiedIconHeight}
|
|
68
72
|
/>
|
|
69
73
|
</p>
|
|
70
74
|
{author?.author_title && <p className={styles.title || ''}>{author?.author_title}</p>}
|
|
@@ -123,7 +127,7 @@ export default function AuthorBox({
|
|
|
123
127
|
author?.biography?.split(' ').length > 30 && isReadMore
|
|
124
128
|
? `${textWordsLimit(author?.biography, 30)} <span class='${
|
|
125
129
|
styles.contReadText
|
|
126
|
-
}'
|
|
130
|
+
}'>${translate(translations, 'cont_read', 'continue reading')}</span>`
|
|
127
131
|
: author?.biography,
|
|
128
132
|
}}
|
|
129
133
|
/>
|
|
@@ -134,11 +138,13 @@ export default function AuthorBox({
|
|
|
134
138
|
title={author?.name}
|
|
135
139
|
className={`${styles.readMore || ''} author-gtm`}
|
|
136
140
|
>
|
|
137
|
-
{
|
|
138
|
-
'[author]'
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
{isReadMore
|
|
142
|
+
? translate(translations, 'read_more_about', 'More about [author]').replace(
|
|
143
|
+
'[author]',
|
|
144
|
+
author?.name.split(' ')[0]
|
|
145
|
+
)
|
|
146
|
+
: translate(translations, 'cont_read', 'continue reading')}
|
|
147
|
+
{contReadIcon}
|
|
142
148
|
</Link>
|
|
143
149
|
)}
|
|
144
150
|
{author?.expertise && (
|
|
@@ -159,7 +165,7 @@ export default function AuthorBox({
|
|
|
159
165
|
<div className={styles.pageInfo || ''}>
|
|
160
166
|
{readingTime && (
|
|
161
167
|
<div className={styles.readingTime || ''}>
|
|
162
|
-
|
|
168
|
+
{readTimeIcon}
|
|
163
169
|
{` ${readingTime} ${translate(translations, 'minutes', 'min')} `}
|
|
164
170
|
<span className={styles.readText || ''}>
|
|
165
171
|
{translate(translations, 'read', 'read')}
|
|
@@ -168,7 +174,13 @@ export default function AuthorBox({
|
|
|
168
174
|
)}
|
|
169
175
|
{reviewer && (
|
|
170
176
|
<div className={styles.reviewer || ''}>
|
|
171
|
-
<img className={styles.check || ''} src={checkCircle} alt="checkCircle" />
|
|
177
|
+
{/* <img className={styles.check || ''} src={checkCircle} alt="checkCircle" /> */}
|
|
178
|
+
<LazyImage
|
|
179
|
+
src={verifiedIcon}
|
|
180
|
+
alt={translate(translations, 'verified', 'Verified')}
|
|
181
|
+
width={verifiedIconWidth}
|
|
182
|
+
height={verifiedIconHeight}
|
|
183
|
+
/>
|
|
172
184
|
<span>{` ${translate(
|
|
173
185
|
translations,
|
|
174
186
|
'fact_checked_by',
|
|
@@ -235,6 +247,10 @@ AuthorBox.propTypes = {
|
|
|
235
247
|
name: PropTypes.string,
|
|
236
248
|
}),
|
|
237
249
|
check: PropTypes.string,
|
|
238
|
-
|
|
250
|
+
verifiedIcon: PropTypes.string,
|
|
251
|
+
verifiedIconWidth: PropTypes.number,
|
|
252
|
+
verifiedIconHeight: PropTypes.number,
|
|
253
|
+
readTimeIcon: PropTypes.node,
|
|
254
|
+
contReadIcon: PropTypes.node,
|
|
239
255
|
showReadMore: PropTypes.bool,
|
|
240
256
|
};
|
|
@@ -18,9 +18,9 @@ const ModuleTitle = ({
|
|
|
18
18
|
if (module.module_title_tag === 'h5') return <h5 id={anchorLabel}>{module.module_title}</h5>;
|
|
19
19
|
if (module.module_title_tag === 'h6') return <h6 id={anchorLabel}>{module.module_title}</h6>;
|
|
20
20
|
return (
|
|
21
|
-
<
|
|
21
|
+
<h2 className={`${styles?.noTag || ''} ${classname || ''}`} id={anchorLabel}>
|
|
22
22
|
{module.module_title}
|
|
23
|
-
</
|
|
23
|
+
</h2>
|
|
24
24
|
);
|
|
25
25
|
};
|
|
26
26
|
// if (
|
|
@@ -61,7 +61,7 @@ describe('Modules Component ', () => {
|
|
|
61
61
|
});
|
|
62
62
|
test('title no tag', () => {
|
|
63
63
|
const { container } = render(<Module module={{ name: 'content', ...contentTableOne }} />);
|
|
64
|
-
expect(container.querySelectorAll('h2')).toHaveLength(
|
|
64
|
+
expect(container.querySelectorAll('h2')).toHaveLength(1);
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
test('Swich for All component', () => {
|
package/src/helpers/schema.js
CHANGED
|
@@ -113,34 +113,61 @@ export function breadcrumbsSchema(breadcrumbs, path) {
|
|
|
113
113
|
return JSON.stringify(generateSchemaObject(schema));
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
export function processSpeakableModules(modules) {
|
|
117
|
+
const speakAbleModules = [];
|
|
118
|
+
|
|
119
|
+
modules.forEach((module) => {
|
|
120
|
+
if (module?.name === 'content' && module.speakable_enabled === '1') {
|
|
121
|
+
const id = module.anchor_slug ? module.anchor_slug : module.module_value_id;
|
|
122
|
+
const htag = module.tag ? module.tag : 'h2';
|
|
123
|
+
const moduleSchema = {
|
|
124
|
+
'@context': 'https://schema.org',
|
|
125
|
+
'@type': 'WebPage',
|
|
126
|
+
name: module.title,
|
|
127
|
+
speakable: {
|
|
128
|
+
'@type': 'SpeakableSpecification',
|
|
129
|
+
cssSelector: [`#${id}>${htag}`, `#${id}>p`],
|
|
130
|
+
},
|
|
131
|
+
url: getUrl(module.path),
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
speakAbleModules.push(JSON.stringify(generateSchemaObject(moduleSchema)));
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
return speakAbleModules;
|
|
139
|
+
}
|
|
140
|
+
|
|
116
141
|
export function webPageSchema(page, pageImage) {
|
|
142
|
+
const speakAbleModules = processSpeakableModules(page?.sections?.main?.modules || []);
|
|
143
|
+
|
|
117
144
|
const schema = {
|
|
118
145
|
'@context': 'https://schema.org',
|
|
119
146
|
'@type': 'WebPage',
|
|
120
|
-
'@id': `${getUrl(page
|
|
121
|
-
url: getUrl(page
|
|
122
|
-
name: page
|
|
123
|
-
description: page
|
|
124
|
-
inLanguage: getLanguage(page
|
|
125
|
-
datePublished: page
|
|
126
|
-
dateModified: page
|
|
147
|
+
'@id': `${getUrl(page?.path)}#webpage`,
|
|
148
|
+
url: getUrl(page?.path),
|
|
149
|
+
name: page?.meta_title || '',
|
|
150
|
+
description: page?.meta_description || '',
|
|
151
|
+
inLanguage: getLanguage(page?.language),
|
|
152
|
+
datePublished: page?.created_at,
|
|
153
|
+
dateModified: page?.updated_at,
|
|
127
154
|
isPartOf: {
|
|
128
155
|
'@type': 'WebSite',
|
|
129
156
|
'@id': `${process.env.GATSBY_SITE_URL}#website`,
|
|
130
157
|
url: `${process.env.GATSBY_SITE_URL}`,
|
|
131
|
-
inLanguage: getLanguage(page
|
|
158
|
+
inLanguage: getLanguage(page?.language),
|
|
132
159
|
},
|
|
133
160
|
author: {
|
|
134
161
|
'@type': 'Organization',
|
|
135
|
-
name: page
|
|
136
|
-
alternateName: page
|
|
137
|
-
foundingDate: page
|
|
138
|
-
publishingPrinciples: page
|
|
162
|
+
name: page?.siteSchema?.site_name || '',
|
|
163
|
+
alternateName: page?.siteSchema?.alias_site_name || '',
|
|
164
|
+
foundingDate: page?.siteSchema?.organization_founding_date || '',
|
|
165
|
+
publishingPrinciples: page?.siteSchema?.publishing_principles,
|
|
139
166
|
logo: {
|
|
140
167
|
'@type': 'ImageObject',
|
|
141
168
|
url: pageImage,
|
|
142
169
|
},
|
|
143
|
-
contactPoint: page
|
|
170
|
+
contactPoint: page?.authors?.map((author) => ({
|
|
144
171
|
'@type': 'ContactPoint',
|
|
145
172
|
contactType: 'Author',
|
|
146
173
|
name: author.name || '',
|
|
@@ -148,11 +175,14 @@ export function webPageSchema(page, pageImage) {
|
|
|
148
175
|
url: getUrl(author.profile_page_path || '/'),
|
|
149
176
|
})),
|
|
150
177
|
sameAs: socialLinks
|
|
151
|
-
.map((socialLink) => page
|
|
178
|
+
.map((socialLink) => page?.siteSchema?.[socialLink])
|
|
152
179
|
.filter((socialLink) => socialLink),
|
|
153
|
-
...(page
|
|
180
|
+
...(page?.knowsAbout ? { knowsAbout: page?.knowsAbout } : {}),
|
|
154
181
|
},
|
|
155
182
|
};
|
|
183
|
+
if (speakAbleModules.length > 0) {
|
|
184
|
+
schema['@speakAbleModules'] = speakAbleModules.map((module) => JSON.parse(module));
|
|
185
|
+
}
|
|
156
186
|
|
|
157
187
|
if (pageImage) {
|
|
158
188
|
schema.primaryImageOfPage = {
|
|
@@ -163,7 +193,7 @@ export function webPageSchema(page, pageImage) {
|
|
|
163
193
|
};
|
|
164
194
|
}
|
|
165
195
|
|
|
166
|
-
if (page
|
|
196
|
+
if (page?.seo_keywords) {
|
|
167
197
|
schema.keywords = page.seo_keywords;
|
|
168
198
|
}
|
|
169
199
|
|
|
@@ -209,6 +239,26 @@ export function moduleSchemas(modules, path) {
|
|
|
209
239
|
}
|
|
210
240
|
return null;
|
|
211
241
|
}
|
|
242
|
+
case 'content': {
|
|
243
|
+
if (module.speakable_enabled === '1') {
|
|
244
|
+
const id = module.anchor_slug ? module.anchor_slug : module.module_value_id;
|
|
245
|
+
const htag = module.tag ? module.tag : 'h2';
|
|
246
|
+
const moduleSchema = {
|
|
247
|
+
'@context': 'https://schema.org',
|
|
248
|
+
'@type': 'WebPage',
|
|
249
|
+
name: module.title,
|
|
250
|
+
speakable: {
|
|
251
|
+
'@type': 'SpeakableSpecification',
|
|
252
|
+
cssSelector: [`#${id}>${htag}`, `#${id}>p`],
|
|
253
|
+
},
|
|
254
|
+
url: getUrl(path),
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
return JSON.stringify(generateSchemaObject(moduleSchema));
|
|
258
|
+
}
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
|
|
212
262
|
default: {
|
|
213
263
|
return null;
|
|
214
264
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getUrl } from './getters';
|
|
2
2
|
import * as Schema from './schema';
|
|
3
|
+
import { processSpeakableModules } from './schema';
|
|
3
4
|
|
|
4
5
|
const parseCheckSchema = (schema) => {
|
|
5
6
|
const json = JSON.parse(schema);
|
|
@@ -34,6 +35,50 @@ describe('Schema Helper', () => {
|
|
|
34
35
|
expect(json.itemListElement[1].item['@id']).toEqual(`${getUrl('breadcrumb_b')}#webpage`);
|
|
35
36
|
});
|
|
36
37
|
|
|
38
|
+
describe('processSpeakableModules()', () => {
|
|
39
|
+
test('should return an empty array if no speakable modules are provided', () => {
|
|
40
|
+
const modules = [
|
|
41
|
+
{ name: 'other' },
|
|
42
|
+
{ name: 'faq', speakable_enabled: '0' },
|
|
43
|
+
{ name: 'content', speakable_enabled: '0' },
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
const result = processSpeakableModules(modules);
|
|
47
|
+
|
|
48
|
+
expect(result).toEqual([]);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('should return an array of speakable modules', () => {
|
|
52
|
+
const modules = [
|
|
53
|
+
{ name: 'other' },
|
|
54
|
+
{
|
|
55
|
+
name: 'content',
|
|
56
|
+
speakable_enabled: '1',
|
|
57
|
+
path: '/content-module',
|
|
58
|
+
title: 'SpeakableTitle',
|
|
59
|
+
tag: 'h2',
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
const result = processSpeakableModules(modules);
|
|
64
|
+
|
|
65
|
+
const expectedResults = [
|
|
66
|
+
JSON.stringify({
|
|
67
|
+
'@context': 'https://schema.org',
|
|
68
|
+
'@type': 'WebPage',
|
|
69
|
+
name: 'SpeakableTitle',
|
|
70
|
+
speakable: {
|
|
71
|
+
'@type': 'SpeakableSpecification',
|
|
72
|
+
cssSelector: ['#undefined>h2', '#undefined>p'], // Updated expected value
|
|
73
|
+
},
|
|
74
|
+
url: getUrl('/content-module'),
|
|
75
|
+
}),
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
expect(result).toEqual(expectedResults);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
37
82
|
test('webPageSchema()', () => {
|
|
38
83
|
const output = Schema.webPageSchema(
|
|
39
84
|
{
|
|
@@ -210,6 +255,29 @@ describe('Schema Helper', () => {
|
|
|
210
255
|
expect(json.mainEntity[2].acceptedAnswer.text).toEqual('Answer C');
|
|
211
256
|
});
|
|
212
257
|
|
|
258
|
+
test('moduleSchemas(content)', () => {
|
|
259
|
+
const output = Schema.moduleSchemas(
|
|
260
|
+
[
|
|
261
|
+
{
|
|
262
|
+
path: 'web_page',
|
|
263
|
+
name: 'content',
|
|
264
|
+
speakable_enabled: '1',
|
|
265
|
+
title: 'SpeakableTitle',
|
|
266
|
+
module_value_id: 1,
|
|
267
|
+
tag: 'h2',
|
|
268
|
+
},
|
|
269
|
+
],
|
|
270
|
+
'/'
|
|
271
|
+
)[0];
|
|
272
|
+
|
|
273
|
+
const json = parseCheckSchema(output);
|
|
274
|
+
expect(json['@type']).toEqual('WebPage');
|
|
275
|
+
expect(json.name).toEqual('SpeakableTitle');
|
|
276
|
+
expect(json.speakable).toBeDefined();
|
|
277
|
+
expect(json.speakable['@type']).toEqual('SpeakableSpecification');
|
|
278
|
+
expect(json.speakable.cssSelector).toEqual(['#1>h2', '#1>p']);
|
|
279
|
+
});
|
|
280
|
+
|
|
213
281
|
test('templateSchemas(null)', () => {
|
|
214
282
|
const output = Schema.templateSchemas({
|
|
215
283
|
relation_type: 'other',
|