@openstack_dev/gatsby-theme-marketing-oif-core 1.0.3 → 1.0.5
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-config.js +189 -178
- package/gatsby-node.js +1 -0
- package/package.json +1 -1
- package/src/components/Seo.js +63 -0
- package/src/content/site-settings/index.json +1 -1
- package/src/pages/index.js +16 -7
- package/src/state/store.js +16 -18
- package/src/utils/urlFormating.js +18 -0
- package/src/utils/useSiteMetadata.js +21 -0
- package/src/utils/useSiteSettings.js +24 -0
package/gatsby-config.js
CHANGED
|
@@ -1,217 +1,228 @@
|
|
|
1
1
|
const path = require("path");
|
|
2
2
|
|
|
3
3
|
require("dotenv").config({
|
|
4
|
-
|
|
4
|
+
path: `.env.${process.env.NODE_ENV}`,
|
|
5
5
|
});
|
|
6
6
|
|
|
7
7
|
const {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
STATIC_CONTENT_DIR_PATH,
|
|
9
|
+
SITE_SETTINGS_FILE_PATH,
|
|
10
|
+
SITE_SETTINGS_DIR_PATH,
|
|
11
11
|
} = require("./src/utils/filePath");
|
|
12
12
|
|
|
13
13
|
let siteSettings = require(`./${SITE_SETTINGS_FILE_PATH}`);
|
|
14
14
|
try {
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
console.log("Falling back to default site settings.")
|
|
15
|
+
siteSettings = require(path.resolve(SITE_SETTINGS_FILE_PATH));
|
|
16
|
+
} catch (e) {
|
|
17
|
+
console.log("Falling back to default site settings.");
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
console.log("loaded siteSettings on gatsby config ...", siteSettings);
|
|
21
|
+
|
|
22
|
+
const title = siteSettings?.siteMetadata?.title || process.env.GATSBY_METADATA_TITLE;
|
|
23
|
+
const description = siteSettings?.siteMetadata?.description
|
|
24
|
+
|| process.env.GATSBY_METADATA_DESCRIPTION;
|
|
23
25
|
const faviconAsset = siteSettings?.favicon?.asset;
|
|
24
26
|
|
|
25
|
-
const manifestPlugin = faviconAsset
|
|
27
|
+
const manifestPlugin = faviconAsset
|
|
28
|
+
? [
|
|
26
29
|
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
]
|
|
30
|
+
resolve: "gatsby-plugin-manifest",
|
|
31
|
+
options: {
|
|
32
|
+
name: title,
|
|
33
|
+
short_name: title,
|
|
34
|
+
description,
|
|
35
|
+
start_url: "/",
|
|
36
|
+
display: "minimal-ui",
|
|
37
|
+
icon: path.join(SITE_SETTINGS_DIR_PATH, faviconAsset),
|
|
38
|
+
include_favicon: true,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
]
|
|
42
|
+
: [];
|
|
39
43
|
|
|
40
44
|
const plugins = [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
...manifestPlugin,
|
|
46
|
+
{
|
|
47
|
+
resolve: "gatsby-alias-imports",
|
|
48
|
+
options: {
|
|
49
|
+
aliases: {
|
|
50
|
+
"@utils": `${__dirname}/src/utils`,
|
|
51
|
+
"@cms": `${__dirname}/src/cms`,
|
|
52
|
+
},
|
|
49
53
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
/**
|
|
57
|
+
* Gatsby v4 uses ES Modules for importing cssModules by default.
|
|
58
|
+
* Disabling this to avoid needing to update in all files and for compatibility
|
|
59
|
+
* with other plugins/packages that have not yet been updated.
|
|
60
|
+
* @see
|
|
61
|
+
* https://www.gatsbyjs.com/docs/reference/release-notes/migrating-from-v2-to-v3/#css-modules-are-imported-as-es-modules
|
|
62
|
+
*
|
|
63
|
+
* Also, since libSass was deprecated in October 2020, the Node Sass package has also been
|
|
64
|
+
* deprecated.
|
|
65
|
+
* As such, we have migrated from Node Sass to Dart Sass in package.json.
|
|
66
|
+
* @see https://www.gatsbyjs.com/plugins/gatsby-plugin-sass/#v300
|
|
67
|
+
* @see https://sass-lang.com/blog/libsass-is-deprecated#how-do-i-migrate
|
|
68
|
+
*/
|
|
69
|
+
resolve: "gatsby-plugin-sass",
|
|
70
|
+
options: {
|
|
71
|
+
cssLoaderOptions: {
|
|
72
|
+
esModule: false,
|
|
73
|
+
modules: {
|
|
74
|
+
namedExport: false,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
71
77
|
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
// Add font assets before markdown or json files
|
|
81
|
+
resolve: "gatsby-source-filesystem",
|
|
82
|
+
options: {
|
|
83
|
+
path: `${__dirname}/static/fonts`,
|
|
84
|
+
name: "fonts",
|
|
79
85
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
resolve: "gatsby-source-filesystem",
|
|
89
|
+
options: {
|
|
90
|
+
path: `${__dirname}/src/pages`,
|
|
91
|
+
name: "pages",
|
|
86
92
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
resolve: "gatsby-source-filesystem",
|
|
96
|
+
options: {
|
|
97
|
+
path: path.resolve(STATIC_CONTENT_DIR_PATH),
|
|
98
|
+
name: "content",
|
|
93
99
|
},
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
resolve: "gatsby-source-filesystem",
|
|
103
|
+
options: {
|
|
104
|
+
path: `${__dirname}/src/data/`,
|
|
105
|
+
name: "data",
|
|
100
106
|
},
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
107
|
+
},
|
|
108
|
+
"gatsby-plugin-image",
|
|
109
|
+
"gatsby-plugin-sharp",
|
|
110
|
+
"gatsby-transformer-sharp",
|
|
111
|
+
"gatsby-transformer-json",
|
|
112
|
+
{
|
|
113
|
+
resolve: "gatsby-transformer-remark",
|
|
114
|
+
options: {
|
|
115
|
+
plugins: [
|
|
116
|
+
{
|
|
117
|
+
resolve: "gatsby-remark-images",
|
|
118
|
+
options: {
|
|
119
|
+
// It"s important to specify the maxWidth (in pixels) of
|
|
120
|
+
// the content container as this plugin uses this as the
|
|
121
|
+
// base for generating different widths of each image.
|
|
122
|
+
maxWidth: 2048,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
],
|
|
120
126
|
},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
resolve: "gatsby-plugin-decap-cms",
|
|
130
|
+
options: {
|
|
131
|
+
modulePath: `${__dirname}/src/cms/cms.js`,
|
|
132
|
+
manualInit: true,
|
|
133
|
+
enableIdentityWidget: false,
|
|
134
|
+
customizeWebpackConfig: (config) => {
|
|
135
|
+
/**
|
|
136
|
+
* Fixes Module not found: Error: Can"t resolve "path" bug.
|
|
137
|
+
* Webpack 5 doesn"t include browser polyfills for node APIs by default anymore,
|
|
138
|
+
* so we need to provide them ourselves.
|
|
139
|
+
* @see https://github.com/postcss/postcss/issues/1509#issuecomment-772097567
|
|
140
|
+
* @see https://github.com/gatsbyjs/gatsby/issues/31475
|
|
141
|
+
* @see https://github.com/gatsbyjs/gatsby/issues/31179#issuecomment-844588682
|
|
142
|
+
*/
|
|
143
|
+
config.resolve = {
|
|
144
|
+
...config.resolve,
|
|
145
|
+
fallback: {
|
|
146
|
+
...config.resolve.fallback,
|
|
147
|
+
path: require.resolve("path-browserify"),
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
},
|
|
145
151
|
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
resolve: "gatsby-plugin-google-tagmanager",
|
|
155
|
+
options: {
|
|
156
|
+
id: process.env.GOOGLE_TAGMANAGER_ID,
|
|
150
157
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
158
|
+
// Include GTM in development.
|
|
159
|
+
//
|
|
160
|
+
// Defaults to false meaning GTM will only be loaded in production.
|
|
161
|
+
includeInDevelopment: false,
|
|
155
162
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
},
|
|
163
|
+
// datalayer to be set before GTM is loaded
|
|
164
|
+
// should be an object or a function that is executed in the browser
|
|
165
|
+
//
|
|
166
|
+
// Defaults to null
|
|
167
|
+
defaultDataLayer: { platform: "gatsby" },
|
|
162
168
|
},
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
resolve: "gatsby-plugin-twitter-pixel",
|
|
172
|
+
options: {
|
|
173
|
+
pixelId: process.env.TWITTER_PIXEL_ID,
|
|
168
174
|
},
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
resolve: "gatsby-plugin-linkedin-insight",
|
|
178
|
+
options: {
|
|
179
|
+
partnerId: process.env.LINKEDIN_INSIGHT_PARTNER_ID,
|
|
173
180
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
181
|
+
// Include LinkedIn Insight in development.
|
|
182
|
+
// Defaults to false meaning LinkedIn Insight will only be loaded in production.
|
|
183
|
+
includeInDevelopment: false,
|
|
178
184
|
},
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
resolve: "gatsby-plugin-quantcast-tag",
|
|
188
|
+
options: {
|
|
189
|
+
acccountId: process.env.QUANTCAST_TAG_ACCOUNT_ID,
|
|
183
190
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
},
|
|
191
|
+
// If true, add tracking code to head. Otherwise, tracking code is
|
|
192
|
+
// added to the bottom of body.
|
|
193
|
+
head: false,
|
|
188
194
|
},
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
resolve: "gatsby-plugin-cookiebot",
|
|
198
|
+
options: {
|
|
199
|
+
cookiebotId: process.env.COOKIEBOT_ID,
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
resolve: "gatsby-plugin-google-fonts-v2",
|
|
204
|
+
options: {
|
|
205
|
+
fonts: [
|
|
206
|
+
{
|
|
207
|
+
family: "Jura:wght@300;400;500;600;700",
|
|
193
208
|
},
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
family: "Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900",
|
|
203
|
-
}
|
|
204
|
-
],
|
|
205
|
-
display: "swap"
|
|
206
|
-
}
|
|
209
|
+
{
|
|
210
|
+
family:
|
|
211
|
+
"Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900",
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
display: "swap",
|
|
207
215
|
},
|
|
208
|
-
|
|
216
|
+
},
|
|
217
|
+
"gatsby-plugin-netlify", // make sure to keep it last in the array
|
|
209
218
|
];
|
|
210
219
|
|
|
220
|
+
console.log(`title ${title} description ${description}`);
|
|
221
|
+
|
|
211
222
|
module.exports = {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
223
|
+
siteMetadata: {
|
|
224
|
+
title,
|
|
225
|
+
description,
|
|
226
|
+
},
|
|
227
|
+
plugins,
|
|
217
228
|
};
|
package/gatsby-node.js
CHANGED
|
@@ -4,6 +4,7 @@ const fs = require("fs");
|
|
|
4
4
|
const webpack = require("webpack");
|
|
5
5
|
const { createFilePath } = require("gatsby-source-filesystem");
|
|
6
6
|
const typeDefs = require("./src/cms/config/collections/typeDefs");
|
|
7
|
+
|
|
7
8
|
require("dotenv").config({
|
|
8
9
|
path: `.env.${process.env.NODE_ENV}`,
|
|
9
10
|
});
|
package/package.json
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import useSiteMetadata from "@utils/useSiteMetadata";
|
|
4
|
+
import useSiteSettings from "@utils/useSiteSettings";
|
|
5
|
+
import { getSrc } from "gatsby-plugin-image";
|
|
6
|
+
import { buildUrl } from "@utils/urlFormating";
|
|
7
|
+
import { getEnvVariable, SITE_URL } from "@utils/envVariables";
|
|
8
|
+
|
|
9
|
+
function Seo({
|
|
10
|
+
title, description, location, children,
|
|
11
|
+
}) {
|
|
12
|
+
const { title: siteTitle, description: defaultDescription } = useSiteMetadata();
|
|
13
|
+
|
|
14
|
+
const siteSettings = useSiteSettings();
|
|
15
|
+
const image = siteSettings?.siteMetadata?.image;
|
|
16
|
+
|
|
17
|
+
const siteUrl = getEnvVariable(SITE_URL);
|
|
18
|
+
const siteUrlInfo = siteUrl ? new URL(siteUrl) : null;
|
|
19
|
+
const scheme = siteUrlInfo ? siteUrlInfo.protocol.replace(":", "") : "https";
|
|
20
|
+
const host = siteUrlInfo ? siteUrlInfo.host : null;
|
|
21
|
+
const { pathname } = location;
|
|
22
|
+
|
|
23
|
+
const seo = {
|
|
24
|
+
title: title ? `${siteTitle} - ${title}` : siteTitle,
|
|
25
|
+
description: description || defaultDescription,
|
|
26
|
+
url: buildUrl(scheme, host, pathname),
|
|
27
|
+
image: host && image ? buildUrl(scheme, host, getSrc(image)) : null,
|
|
28
|
+
};
|
|
29
|
+
console.log("SEO", seo);
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
{seo.title && <title>{seo.title}</title>}
|
|
33
|
+
{seo.description && <meta name="description" content={seo.description} />}
|
|
34
|
+
{seo.url && <meta property="og:url" content={seo.url} />}
|
|
35
|
+
<meta property="og:type" content="website" />
|
|
36
|
+
{seo.title && <meta property="og:title" content={seo.title} />}
|
|
37
|
+
{seo.description && (
|
|
38
|
+
<meta property="og:description" content={seo.description} />
|
|
39
|
+
)}
|
|
40
|
+
{seo.image && <meta property="og:image" content={seo.image} />}
|
|
41
|
+
{seo.image && <meta name="twitter:card" content="summary_large_image" />}
|
|
42
|
+
{host && <meta property="twitter:domain" content={host} />}
|
|
43
|
+
{seo.url && <meta property="twitter:url" content={seo.url} />}
|
|
44
|
+
{seo.title && <meta name="twitter:title" content={seo.title} />}
|
|
45
|
+
{seo.description && (
|
|
46
|
+
<meta name="twitter:description" content={seo.description} />
|
|
47
|
+
)}
|
|
48
|
+
{seo.image && <meta name="twitter:image" content={seo.image} />}
|
|
49
|
+
{children}
|
|
50
|
+
</>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
Seo.propTypes = {
|
|
55
|
+
title: PropTypes.string,
|
|
56
|
+
description: PropTypes.string,
|
|
57
|
+
location: PropTypes.shape({
|
|
58
|
+
pathname: PropTypes.string.isRequired,
|
|
59
|
+
}).isRequired,
|
|
60
|
+
children: PropTypes.node,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default Seo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "staticJsonFilesBuildTime": [], "lastBuild":
|
|
1
|
+
{ "staticJsonFilesBuildTime": [], "lastBuild": 1713843468311 }
|
package/src/pages/index.js
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Layout from "../components/Layout";
|
|
3
3
|
import CustomGoogleTracker from "../components/Tracking/custom-google-tracker";
|
|
4
|
+
import Seo from "../components/Seo";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
function IndexPage() {
|
|
7
|
+
return (
|
|
8
|
+
<Layout>
|
|
9
|
+
<div style={{ height: 300 }}>placeholder</div>
|
|
10
|
+
</Layout>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
6
13
|
|
|
7
14
|
export default IndexPage;
|
|
8
15
|
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
export function Head({ location }) {
|
|
17
|
+
return (
|
|
18
|
+
<>
|
|
19
|
+
<Seo location={location} />
|
|
20
|
+
<CustomGoogleTracker />
|
|
21
|
+
</>
|
|
22
|
+
);
|
|
23
|
+
}
|
package/src/state/store.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { applyMiddleware, compose, createStore } from "redux";
|
|
2
2
|
import { persistCombineReducers, persistStore } from "redux-persist";
|
|
3
|
-
import storage from "
|
|
3
|
+
import storage from "redux-persist/lib/storage";
|
|
4
4
|
import thunk from "redux-thunk";
|
|
5
5
|
|
|
6
6
|
import * as reducers from "../reducers";
|
|
@@ -9,35 +9,33 @@ import * as reducers from "../reducers";
|
|
|
9
9
|
const clientId = process.env.GATSBY_OAUTH2_CLIENT_ID;
|
|
10
10
|
|
|
11
11
|
const config = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
key: `root_${clientId}`,
|
|
13
|
+
storage,
|
|
14
|
+
blacklist: [
|
|
15
|
+
// this will be not saved to persistent storage see
|
|
16
|
+
// https://github.com/rt2zz/redux-persist#blacklist--whitelist
|
|
17
|
+
],
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const states = {
|
|
21
|
-
|
|
21
|
+
loggedUserState: reducers.loggedUserReducer,
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
const appendLoggedUser = (
|
|
25
|
-
return next(action);
|
|
26
|
-
};
|
|
24
|
+
const appendLoggedUser = () => (next) => (action) => next(action);
|
|
27
25
|
|
|
28
26
|
const composeEnhancers = typeof window === "object" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
|
28
|
+
: compose;
|
|
31
29
|
|
|
32
30
|
const enhancer = composeEnhancers(applyMiddleware(appendLoggedUser, thunk));
|
|
33
31
|
|
|
34
32
|
// Create store with persistor
|
|
35
33
|
export const { store, persistor } = (() => {
|
|
36
|
-
|
|
34
|
+
const persistedReducers = persistCombineReducers(config, states);
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
const store = createStore(persistedReducers, enhancer);
|
|
37
|
+
const onRehydrateComplete = () => {};
|
|
38
|
+
const persistor = persistStore(store, null, onRehydrateComplete);
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
return { store, persistor };
|
|
43
41
|
})();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const buildUrl = (scheme, host, pathname) => {
|
|
2
|
+
if (!host) return null;
|
|
3
|
+
const domain = `${scheme}://${host}`;
|
|
4
|
+
return `${domain}${pathname ?? "/"}`;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const getSponsorURL = (id, name) => {
|
|
8
|
+
const formattedName = name.toLowerCase().replace(/\s/g, "-");
|
|
9
|
+
return `${id}-${formattedName}`;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const titleFromPathname = (pathname) => {
|
|
13
|
+
const segments = pathname.split("/");
|
|
14
|
+
const lastSegment = segments.filter(Boolean).pop();
|
|
15
|
+
return lastSegment
|
|
16
|
+
?.replace("-", " ")
|
|
17
|
+
.replace(/\b\w/g, (word) => word.toUpperCase());
|
|
18
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { graphql, useStaticQuery } from "gatsby";
|
|
2
|
+
|
|
3
|
+
const siteMetadataQuery = graphql`
|
|
4
|
+
query {
|
|
5
|
+
site {
|
|
6
|
+
siteMetadata {
|
|
7
|
+
title
|
|
8
|
+
description
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
const useSiteMetadata = () => {
|
|
15
|
+
const {
|
|
16
|
+
site: { siteMetadata },
|
|
17
|
+
} = useStaticQuery(siteMetadataQuery);
|
|
18
|
+
return siteMetadata;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default useSiteMetadata;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { graphql, useStaticQuery } from "gatsby";
|
|
2
|
+
|
|
3
|
+
const siteSettingsQuery = graphql`
|
|
4
|
+
query {
|
|
5
|
+
siteSettingsJson {
|
|
6
|
+
siteMetadata {
|
|
7
|
+
title
|
|
8
|
+
description
|
|
9
|
+
image {
|
|
10
|
+
childImageSharp {
|
|
11
|
+
gatsbyImageData(quality: 100)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const useSiteSettings = () => {
|
|
20
|
+
const { siteSettingsJson } = useStaticQuery(siteSettingsQuery);
|
|
21
|
+
return siteSettingsJson;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default useSiteSettings;
|