@openstack_dev/gatsby-theme-marketing-oif-core 1.0.3 → 1.0.4

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