@griddo/cx 1.72.9 → 1.73.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/gatsby-node.js +7 -8
- package/package.json +6 -6
- package/src/api/index.js +1 -1
- package/src/components/template.js +9 -17
- package/src/utils/cache.js +24 -0
- package/static/robots.txt +1 -0
package/gatsby-node.js
CHANGED
|
@@ -7,7 +7,7 @@ const NavigationService = require('./src/services/navigation').default;
|
|
|
7
7
|
const SitesService = require('./src/services/sites').default;
|
|
8
8
|
const SettingsService = require('./src/services/settings').default;
|
|
9
9
|
const RobotsService = require('./src/services/robots').default;
|
|
10
|
-
const { initCache } = require('./src/utils/cache');
|
|
10
|
+
const { initCache, updatedSiteHash } = require('./src/utils/cache');
|
|
11
11
|
|
|
12
12
|
const {
|
|
13
13
|
isComponentLibraryEnv,
|
|
@@ -103,11 +103,8 @@ exports.onPreInit = async () => {
|
|
|
103
103
|
exports.createPages = async ({ actions }) => {
|
|
104
104
|
// fetch
|
|
105
105
|
for (const site of updatedSites) {
|
|
106
|
-
const cache = !site.shouldBeUpdated;
|
|
107
106
|
const NavService = new NavigationService();
|
|
108
|
-
|
|
109
|
-
const { id: siteID, slug: siteSlug, theme, favicon } = site;
|
|
110
|
-
|
|
107
|
+
const { id: siteId, slug: siteSlug, theme, favicon } = site;
|
|
111
108
|
const {
|
|
112
109
|
siteInfo,
|
|
113
110
|
validPagesIds,
|
|
@@ -118,7 +115,9 @@ exports.createPages = async ({ actions }) => {
|
|
|
118
115
|
headers,
|
|
119
116
|
footers,
|
|
120
117
|
socials,
|
|
121
|
-
} = await sites.getSiteData(
|
|
118
|
+
} = await sites.getSiteData(siteId);
|
|
119
|
+
|
|
120
|
+
const cache = updatedSiteHash(siteId, siteHash);
|
|
122
121
|
|
|
123
122
|
site.languages = siteLangs;
|
|
124
123
|
|
|
@@ -133,7 +132,7 @@ exports.createPages = async ({ actions }) => {
|
|
|
133
132
|
footers,
|
|
134
133
|
};
|
|
135
134
|
|
|
136
|
-
buildProcessData[
|
|
135
|
+
buildProcessData[siteId] = {
|
|
137
136
|
siteHash,
|
|
138
137
|
unpublishHashes,
|
|
139
138
|
publishHashes: [],
|
|
@@ -219,7 +218,7 @@ exports.createPages = async ({ actions }) => {
|
|
|
219
218
|
actions.createPage
|
|
220
219
|
);
|
|
221
220
|
|
|
222
|
-
buildProcessData[
|
|
221
|
+
buildProcessData[siteId].publishHashes.push(page.hash);
|
|
223
222
|
}
|
|
224
223
|
}
|
|
225
224
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/cx",
|
|
3
3
|
"description": "Griddo SSG based on Gatsby",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.73.0",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Carlos Torres <carlos.torres@secuoyas.com>",
|
|
@@ -53,19 +53,19 @@
|
|
|
53
53
|
"gatsby-plugin-react-helmet": "^5.8.0",
|
|
54
54
|
"gatsby-plugin-react-svg": "^3.1.0",
|
|
55
55
|
"gatsby-plugin-remove-generator": "^1.2.0",
|
|
56
|
-
"gatsby-plugin-sass": "^5.
|
|
56
|
+
"gatsby-plugin-sass": "^5.21.0",
|
|
57
57
|
"gatsby-plugin-styled-components": "^5.8.0",
|
|
58
58
|
"html-react-parser": "^1.4.10",
|
|
59
59
|
"js2xmlparser": "^4.0.1",
|
|
60
|
-
"node-sass": "^7.0.1",
|
|
61
60
|
"opn": "^6.0.0",
|
|
62
61
|
"path-browserify": "^1.0.1",
|
|
63
62
|
"pkg-dir": "^5.0.0",
|
|
64
63
|
"process": "^0.11.10",
|
|
65
|
-
"react-helmet": "^6.0.0"
|
|
64
|
+
"react-helmet": "^6.0.0",
|
|
65
|
+
"sass": "^1.54.5"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@griddo/eslint-config-back": "^1.
|
|
68
|
+
"@griddo/eslint-config-back": "^1.73.0",
|
|
69
69
|
"eslint": "^7.5.0",
|
|
70
70
|
"eslint-plugin-node": "^11.1.0",
|
|
71
71
|
"eslint-plugin-react": "7.14.3",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"publishConfig": {
|
|
98
98
|
"access": "public"
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "39770a163c7efb63faf94e9ba72e3d1d866dca18"
|
|
101
101
|
}
|
package/src/api/index.js
CHANGED
|
@@ -5,7 +5,7 @@ const { saveCache, getCache } = require('../utils/cache');
|
|
|
5
5
|
require("dotenv").config()
|
|
6
6
|
|
|
7
7
|
const getApi = async (endpoint, body, cached = false) => {
|
|
8
|
-
const cacheOptions = { endpoint, body };
|
|
8
|
+
const cacheOptions = { endpoint, body, cached };
|
|
9
9
|
if (cached) {
|
|
10
10
|
const cachedResponse = getCache(cacheOptions);
|
|
11
11
|
if (cachedResponse) return cachedResponse;
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
/* eslint-disable node/no-extraneous-import */
|
|
2
|
-
import * as React from
|
|
3
|
-
import { Link, navigate } from
|
|
4
|
-
import Seo from
|
|
5
|
-
import { composeAnalytics } from
|
|
6
|
-
import {
|
|
7
|
-
generateAutomaticDimensions,
|
|
8
|
-
components,
|
|
9
|
-
templates,
|
|
10
|
-
SiteProvider,
|
|
11
|
-
} from 'components';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Link, navigate } from "gatsby";
|
|
4
|
+
import Seo from "./seo";
|
|
5
|
+
import { composeAnalytics } from "../utils/dataLayer";
|
|
6
|
+
import { generateAutomaticDimensions, components, templates, SiteProvider } from "components";
|
|
12
7
|
|
|
13
|
-
import { Page as RenderGriddoPage } from
|
|
8
|
+
import { Page as RenderGriddoPage } from "@griddo/core";
|
|
14
9
|
|
|
15
|
-
export default data => {
|
|
10
|
+
export default (data) => {
|
|
16
11
|
const {
|
|
17
12
|
page: content,
|
|
18
13
|
locale,
|
|
@@ -37,12 +32,9 @@ export default data => {
|
|
|
37
32
|
templates,
|
|
38
33
|
};
|
|
39
34
|
|
|
40
|
-
const mappedTheme = theme ||
|
|
35
|
+
const mappedTheme = theme || "default-theme";
|
|
41
36
|
|
|
42
|
-
const { analyticsScript, analyticsDimensions } = composeAnalytics(
|
|
43
|
-
data,
|
|
44
|
-
generateAutomaticDimensions
|
|
45
|
-
);
|
|
37
|
+
const { analyticsScript, analyticsDimensions } = composeAnalytics(data, generateAutomaticDimensions);
|
|
46
38
|
|
|
47
39
|
if (!content.dimensions) content.dimensions = [];
|
|
48
40
|
content.dimensions.values = analyticsDimensions;
|
package/src/utils/cache.js
CHANGED
|
@@ -4,6 +4,7 @@ const crypto = require('crypto');
|
|
|
4
4
|
|
|
5
5
|
const apiCacheDirectory = './apiCache';
|
|
6
6
|
const gatsbyCacheDirectory = path.resolve(__dirname, './../../.cache');
|
|
7
|
+
const siteHashFilename = `${apiCacheDirectory}/siteHash.json`;
|
|
7
8
|
|
|
8
9
|
const initCache = () => {
|
|
9
10
|
// TODO: Make a domain-based cache to store and restore
|
|
@@ -39,8 +40,31 @@ const getCache = petition => {
|
|
|
39
40
|
}
|
|
40
41
|
};
|
|
41
42
|
|
|
43
|
+
const getHashSites = () => {
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(fs.readFileSync(siteHashFilename)) || {};
|
|
46
|
+
} catch {
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const updatedSiteHash = (siteId, siteHash) => {
|
|
52
|
+
const allHash = getHashSites();
|
|
53
|
+
|
|
54
|
+
const lastHash = allHash[siteId];
|
|
55
|
+
const currentHash = siteHash || lastHash || new Date().valueOf();
|
|
56
|
+
|
|
57
|
+
if (currentHash !== lastHash) {
|
|
58
|
+
allHash[siteId] = currentHash;
|
|
59
|
+
fs.writeFileSync(siteHashFilename, JSON.stringify(allHash), 'utf8');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return currentHash;
|
|
63
|
+
};
|
|
64
|
+
|
|
42
65
|
module.exports = {
|
|
43
66
|
initCache,
|
|
44
67
|
saveCache,
|
|
45
68
|
getCache,
|
|
69
|
+
updatedSiteHash,
|
|
46
70
|
};
|
package/static/robots.txt
CHANGED