gatsby-core-theme 2.0.15 → 2.0.16
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 +10 -0
- package/gatsby-node.esm.js +10 -4
- package/package.json +1 -1
- package/src/helpers/generators.js +2 -2
- package/src/helpers/generators.test.js +25 -25
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## [2.0.16](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v2.0.15...v2.0.16) (2022-01-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update-placeholder-generation-with-title ([92e3cf2](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/92e3cf2663345ddaffb040504f4830d445d2f73c))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
* Merge branch 'hotfix-update-placeholder-generation-with-title' into 'master' ([44d05d6](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/44d05d648d49bdb2d5776d7133e3b569ac1f6353))
|
|
10
|
+
|
|
1
11
|
## [2.0.15](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v2.0.14...v2.0.15) (2022-01-05)
|
|
2
12
|
|
|
3
13
|
|
package/gatsby-node.esm.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { cloneDeep, chunk, pick } from 'lodash';
|
|
6
6
|
import chalk from 'chalk';
|
|
7
7
|
import { getData, getLocalData } from './src/helpers/api';
|
|
8
|
-
import {
|
|
8
|
+
import { generatePlaceholderString, generateTrackerLink } from './src/helpers/generators';
|
|
9
9
|
import processor, { processSitemapPages } from './src/helpers/processor';
|
|
10
10
|
import { pickAuthorsPageKeys } from './src/constants/pick-keys';
|
|
11
11
|
|
|
@@ -204,16 +204,22 @@ exports.createPages = async ({ actions: { createPage } }, themeOptions) => {
|
|
|
204
204
|
pick(authors[key], pickAuthorsPageKeys)
|
|
205
205
|
);
|
|
206
206
|
|
|
207
|
-
// replacing
|
|
207
|
+
// replacing string placehoders with year, month, date, etc.
|
|
208
|
+
page.title =
|
|
209
|
+
page.title &&
|
|
210
|
+
generatePlaceholderString(page.title, translations, {
|
|
211
|
+
siteName: response.general.site_name,
|
|
212
|
+
siteTitle: page.title,
|
|
213
|
+
});
|
|
208
214
|
page.meta_title =
|
|
209
215
|
page.meta_title &&
|
|
210
|
-
|
|
216
|
+
generatePlaceholderString(page.meta_title, translations, {
|
|
211
217
|
siteName: response.general.site_name,
|
|
212
218
|
siteTitle: page.title,
|
|
213
219
|
});
|
|
214
220
|
page.meta_description =
|
|
215
221
|
page.meta_description &&
|
|
216
|
-
|
|
222
|
+
generatePlaceholderString(page.meta_description, translations, {
|
|
217
223
|
siteName: response.general.site_name,
|
|
218
224
|
siteTitle: page.title,
|
|
219
225
|
});
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ export function generateTrackerLink(operator, trackerType) {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export function
|
|
24
|
+
export function generatePlaceholderString(string, translations, props) {
|
|
25
25
|
const date = new Date();
|
|
26
26
|
const day = date.getDate();
|
|
27
27
|
const month = months[date.getMonth()];
|
|
@@ -29,7 +29,7 @@ export function generateMetaString(metaString, translations, props) {
|
|
|
29
29
|
const regex =
|
|
30
30
|
/\[MONTH\]|\[YEAR\]|\[currentyear\]|\[sitename\]|\[currentmonth\]|\[title\]|\[currentdate\]/gi;
|
|
31
31
|
|
|
32
|
-
return
|
|
32
|
+
return string.replace(
|
|
33
33
|
regex,
|
|
34
34
|
(match) =>
|
|
35
35
|
({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { generateTrackerLink,
|
|
1
|
+
import { generateTrackerLink, generatePlaceholderString } from './generators';
|
|
2
2
|
import { months } from '~constants/common';
|
|
3
3
|
|
|
4
4
|
describe('Generate Tracker Link Helper', () => {
|
|
@@ -16,19 +16,19 @@ describe('Generate Tracker Link Helper', () => {
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
describe('Generate
|
|
20
|
-
test('
|
|
21
|
-
const
|
|
19
|
+
describe('Generate Placeholders String', () => {
|
|
20
|
+
test('generatePlaceholderString uppercase', () => {
|
|
21
|
+
const string = generatePlaceholderString('Some title [MONTH] [YEAR]');
|
|
22
22
|
const date = new Date();
|
|
23
23
|
|
|
24
|
-
expect(
|
|
25
|
-
expect(
|
|
26
|
-
expect(
|
|
27
|
-
expect(
|
|
24
|
+
expect(string).not.toContain('[MONTH]');
|
|
25
|
+
expect(string).not.toContain('[YEAR]');
|
|
26
|
+
expect(string).toContain(date.getFullYear());
|
|
27
|
+
expect(string).toContain(months[date.getMonth()]);
|
|
28
28
|
});
|
|
29
|
-
test('
|
|
30
|
-
const
|
|
31
|
-
'
|
|
29
|
+
test('generatePlaceholderString lowercase', () => {
|
|
30
|
+
const string = generatePlaceholderString(
|
|
31
|
+
'Some title [currentdate] [currentmonth] [currentyear] [sitename] [title]',
|
|
32
32
|
null,
|
|
33
33
|
{
|
|
34
34
|
siteName: 'Site Name',
|
|
@@ -37,26 +37,26 @@ describe('Generate Meta Title Helper', () => {
|
|
|
37
37
|
);
|
|
38
38
|
const date = new Date();
|
|
39
39
|
|
|
40
|
-
expect(
|
|
41
|
-
expect(
|
|
42
|
-
expect(
|
|
43
|
-
expect(
|
|
44
|
-
expect(
|
|
45
|
-
expect(
|
|
46
|
-
expect(
|
|
47
|
-
expect(
|
|
48
|
-
expect(
|
|
49
|
-
expect(
|
|
40
|
+
expect(string).not.toContain('[currentdate]');
|
|
41
|
+
expect(string).not.toContain('[currentmonth]');
|
|
42
|
+
expect(string).not.toContain('[currentyear]');
|
|
43
|
+
expect(string).not.toContain('[sitename]');
|
|
44
|
+
expect(string).not.toContain('[title]');
|
|
45
|
+
expect(string).toContain(date.getDate());
|
|
46
|
+
expect(string).toContain(months[date.getMonth()]);
|
|
47
|
+
expect(string).toContain(date.getFullYear());
|
|
48
|
+
expect(string).toContain('Site Name');
|
|
49
|
+
expect(string).toContain('Site Title');
|
|
50
50
|
});
|
|
51
|
-
test('
|
|
51
|
+
test('generatePlaceholderString translated', () => {
|
|
52
52
|
const translateMonths = months.reduce(
|
|
53
53
|
(translated, month) => ({ ...translated, [month]: `translate${month.substring(0, 1)}` }),
|
|
54
54
|
{}
|
|
55
55
|
);
|
|
56
|
-
const
|
|
56
|
+
const string = generatePlaceholderString('Some title [MONTH]', translateMonths);
|
|
57
57
|
const date = new Date();
|
|
58
58
|
|
|
59
|
-
expect(
|
|
60
|
-
expect(
|
|
59
|
+
expect(string).not.toContain('[MONTH]');
|
|
60
|
+
expect(string).toContain(translateMonths[months[date.getMonth()]]);
|
|
61
61
|
});
|
|
62
62
|
});
|