sfc-utils 1.4.76 → 1.4.78
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/brands3.js +224 -0
- package/components/helpers/utilfunctions.mjs +3 -3
- package/components/layout/layouthelmet.mjs +78 -53
- package/copy/sheets.js +72 -21
- package/css/nav2.less +1 -1
- package/example/gatsby-config.js +2 -2
- package/index.js +2 -0
- package/package.json +1 -1
- package/styles/brandStylesCommon.less +7 -3
package/brands3.js
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
|
|
2
|
+
// Set brand object to override CSS based on this market's styles
|
|
3
|
+
let getBrands3 = function(market){
|
|
4
|
+
// We can add any Hearst global overrides here:
|
|
5
|
+
let defaultObj = {
|
|
6
|
+
styles: {
|
|
7
|
+
"@alert-red": "#d20000",
|
|
8
|
+
// Defaults
|
|
9
|
+
"@display": '"Archivo", Arial, sans-serif',
|
|
10
|
+
"@body": '"Mulish", Verdana, sans-serif',
|
|
11
|
+
"@secondary": '"Rubik", Arial, sans-serif',
|
|
12
|
+
//backwards compatible
|
|
13
|
+
"@hed": '"Archivo", Arial, sans-serif',
|
|
14
|
+
"@hed-alt": '"Archivo", Arial, sans-serif',
|
|
15
|
+
"@serif": '"Mulish", Verdana, sans-serif',
|
|
16
|
+
"@sans": '"Rubik", Arial, sans-serif',
|
|
17
|
+
"@sans-alt": '"Rubik", Arial, sans-serif',
|
|
18
|
+
|
|
19
|
+
// Icons
|
|
20
|
+
"@sub-icon": `url('data:image/svg+xml, <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" fill="white"><path d="M160 416H96c-17.67 0-32-14.33-32-32V128c0-17.67 14.33-32 32-32h64c17.67 0 32-14.33 32-32S177.7 32 160 32H96C42.98 32 0 74.98 0 128v256c0 53.02 42.98 96 96 96h64c17.67 0 32-14.33 32-32S177.7 416 160 416zM502.6 233.4l-128-128c-12.51-12.51-32.76-12.49-45.25 0c-12.5 12.5-12.5 32.75 0 45.25L402.8 224H192C174.3 224 160 238.3 160 256s14.31 32 32 32h210.8l-73.38 73.38c-12.5 12.5-12.5 32.75 0 45.25s32.75 12.5 45.25 0l128-128C515.1 266.1 515.1 245.9 502.6 233.4z"/></svg>')`,
|
|
21
|
+
},
|
|
22
|
+
attributes: {
|
|
23
|
+
"subscribeLink": "https://www.hearst.com/newspapers?projects=true"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Handle market-specific styles here:
|
|
28
|
+
let marketObj = {
|
|
29
|
+
/* San Franicsco Chronicle */
|
|
30
|
+
SFC: {
|
|
31
|
+
styles: {
|
|
32
|
+
"@brand": "#26A0A5",
|
|
33
|
+
"@brand-secondary": "#FFBC30",
|
|
34
|
+
"@display": '"Tiempos Headline", "Baskerville", Georgia, serif',
|
|
35
|
+
"@body": '"Tiempos", "Baskerville", Georgia, serif',
|
|
36
|
+
"@secondary": '"National", Arial, Helvetica, sans-serif',
|
|
37
|
+
//backwards compatible
|
|
38
|
+
"@hed": '"Tiempos Headline", "Baskerville", Georgia, serif',
|
|
39
|
+
"@hed-alt": '"Tiempos Headline", "Baskerville", Georgia, serif',
|
|
40
|
+
"@serif": '"Tiempos", "Baskerville", Georgia, serif',
|
|
41
|
+
"@sans": '"National", Arial, Helvetica, sans-serif',
|
|
42
|
+
"@sans-alt": '"National", Arial, Helvetica, sans-serif'
|
|
43
|
+
},
|
|
44
|
+
attributes: {
|
|
45
|
+
"marketPrefix": "sf",
|
|
46
|
+
"siteName": "The San Francisco Chronicle",
|
|
47
|
+
"twitter": "sfchronicle",
|
|
48
|
+
"gaAccount": "UA-1616916-26",
|
|
49
|
+
"subscribeLink": "https://www.sfchronicle.com/subproject",
|
|
50
|
+
"sailCustomer": "fca2a0390286f0e53120a668534d9529",
|
|
51
|
+
"sailSiteName": "san-francisco-chronicle",
|
|
52
|
+
"siteId": 35,
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
/* Houston Chronicle */
|
|
57
|
+
Houston: {
|
|
58
|
+
styles: {
|
|
59
|
+
"@brand": "#CB0024",
|
|
60
|
+
"@brand-secondary": "#1C2146"
|
|
61
|
+
},
|
|
62
|
+
attributes: {
|
|
63
|
+
"marketPrefix": "hc",
|
|
64
|
+
"siteName": "The Houston Chronicle",
|
|
65
|
+
"twitter": "HoustonChron",
|
|
66
|
+
"invert": true,
|
|
67
|
+
"gaAccount": "UA-1616916-24",
|
|
68
|
+
"subscribeLink": "https://www.houstonchronicle.com/subproject",
|
|
69
|
+
"sailCustomer": "48e30b5083cf6bf47c519651453c9e8a",
|
|
70
|
+
"sailSiteName": "houston-chronicle",
|
|
71
|
+
"siteId": 33
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
/* Albany Times Union */
|
|
76
|
+
Albany: {
|
|
77
|
+
styles: {
|
|
78
|
+
"@brand": "#006FBA",
|
|
79
|
+
"@brand-secondary": "#E5A72C"
|
|
80
|
+
},
|
|
81
|
+
attributes: {
|
|
82
|
+
"marketPrefix": "tu",
|
|
83
|
+
"siteName": "Times Union",
|
|
84
|
+
"twitter": "timesunion",
|
|
85
|
+
"invert": true,
|
|
86
|
+
"gaAccount": "UA-1616916-7",
|
|
87
|
+
"subscribeLink": "https://www.timesunion.com/subproject",
|
|
88
|
+
"sailCustomer": "5bb9eee089bdc2e27cbd265535ad1f90",
|
|
89
|
+
"sailSiteName": "times-union",
|
|
90
|
+
"siteId": 3
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
/* San Antonio Express News */
|
|
95
|
+
SanAntonio: {
|
|
96
|
+
styles: {
|
|
97
|
+
"@brand": "#BA142D",
|
|
98
|
+
"@brand-secondary": "#189196"
|
|
99
|
+
},
|
|
100
|
+
attributes: {
|
|
101
|
+
"marketPrefix": "sa",
|
|
102
|
+
"siteName": "Express-News",
|
|
103
|
+
"twitter": "ExpressNews",
|
|
104
|
+
"invert": true,
|
|
105
|
+
"gaAccount": "UA-1616916-27",
|
|
106
|
+
"subscribeLink": "https://www.expressnews.com/subproject",
|
|
107
|
+
"sailCustomer": "aec52c4681ed63b5beab139a2584f0d4",
|
|
108
|
+
"sailSiteName": "san-antonio-express-news",
|
|
109
|
+
"siteId": 36
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
/* Connecticut */
|
|
114
|
+
CT: {
|
|
115
|
+
styles: {
|
|
116
|
+
"@brand": "#1A98FF",
|
|
117
|
+
"@brand-secondary": "#FFBC30"
|
|
118
|
+
},
|
|
119
|
+
attributes: {
|
|
120
|
+
"marketPrefix": "in",
|
|
121
|
+
"siteName": "CTInsider",
|
|
122
|
+
"twitter": "insider_ct",
|
|
123
|
+
"invert": true,
|
|
124
|
+
"gaAccount": "UA-1616916-99",
|
|
125
|
+
"subscribeLink": "https://www.ctinsider.com/subproject",
|
|
126
|
+
"sailCustomer": "9b21160afa226c9f84d27b47c3d52364",
|
|
127
|
+
"sailSiteName": "ct-insider",
|
|
128
|
+
"siteId": 61
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
/* Communities */
|
|
133
|
+
Texcom: {
|
|
134
|
+
styles: {
|
|
135
|
+
"@brand": "#900900",
|
|
136
|
+
"@brand-secondary": "#189196"
|
|
137
|
+
},
|
|
138
|
+
attributes: {
|
|
139
|
+
"marketPrefix": "texcom/mrt",
|
|
140
|
+
"siteName": "Midland Reporter-Telegram",
|
|
141
|
+
"twitter": "mwtnews",
|
|
142
|
+
"invert": true,
|
|
143
|
+
"gaAccount": "UA-1616916-99",
|
|
144
|
+
"subscribeLink": "/subproject",
|
|
145
|
+
"sailCustomer": "4a181de0b63a131cf27f8ea9485e5e1c",
|
|
146
|
+
"sailSiteName": "midland-reporter-telegram",
|
|
147
|
+
"siteId": 57
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
Midcom: {
|
|
151
|
+
styles: {
|
|
152
|
+
"@brand": "#900900",
|
|
153
|
+
"@brand-secondary": "#189196"
|
|
154
|
+
},
|
|
155
|
+
attributes: {
|
|
156
|
+
"marketPrefix": "midcom/mid",
|
|
157
|
+
"siteName": "Midland Daily News",
|
|
158
|
+
"twitter": "MDN",
|
|
159
|
+
"invert": true,
|
|
160
|
+
"gaAccount": "UA-1616916-99",
|
|
161
|
+
"subscribeLink": "/subproject",
|
|
162
|
+
"sailCustomer": "4a181de0b63a131cf27f8ea9485e5e1c",
|
|
163
|
+
"sailSiteName": "midland-daily-news",
|
|
164
|
+
"siteId": 61
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
Conroe: {
|
|
168
|
+
styles: {
|
|
169
|
+
"@brand": "#900900",
|
|
170
|
+
"@brand-secondary": "#189196"
|
|
171
|
+
},
|
|
172
|
+
attributes: {
|
|
173
|
+
"marketPrefix": "conroe",
|
|
174
|
+
"siteName": "Conroe Courier",
|
|
175
|
+
"twitter": "ConroeCourier",
|
|
176
|
+
"invert": true,
|
|
177
|
+
"gaAccount": "UA-1616916-99",
|
|
178
|
+
"subscribeLink": "https://www.yourconroenews.com/subproject",
|
|
179
|
+
"sailCustomer": "4a181de0b63a131cf27f8ea9485e5e1c",
|
|
180
|
+
"sailSiteName": "the-courier-of-montgomery-county",
|
|
181
|
+
"siteId": 68
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
Seattle: {
|
|
185
|
+
styles: {
|
|
186
|
+
"@brand": "#3F8395",
|
|
187
|
+
"@brand-secondary": "#189196"
|
|
188
|
+
},
|
|
189
|
+
attributes: {
|
|
190
|
+
"marketPrefix": "seattle",
|
|
191
|
+
"siteName": "Seattle PI",
|
|
192
|
+
"twitter": "seattlepi",
|
|
193
|
+
"invert": true,
|
|
194
|
+
"gaAccount": "UA-1616916-99",
|
|
195
|
+
"subscribeLink": "",
|
|
196
|
+
"sailCustomer": "da30899589786517b0c0cead37a48b06",
|
|
197
|
+
"sailSiteName": "seattle-post-intelligencer",
|
|
198
|
+
"siteId": 20
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
/* Misc */
|
|
202
|
+
TK: {
|
|
203
|
+
styles: {
|
|
204
|
+
"@brand": "#900900",
|
|
205
|
+
"@brand-secondary": "#189196"
|
|
206
|
+
},
|
|
207
|
+
attributes: {
|
|
208
|
+
"marketPrefix": "tk",
|
|
209
|
+
"siteName": "Hearst Digital News",
|
|
210
|
+
"twitter": "Hearst",
|
|
211
|
+
"invert": true,
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Combine global and market styles to return the final object
|
|
217
|
+
let combinedStyles = {
|
|
218
|
+
styles: Object.assign(defaultObj.styles, marketObj[market].styles),
|
|
219
|
+
attributes: Object.assign(defaultObj.attributes, marketObj[market].attributes)
|
|
220
|
+
}
|
|
221
|
+
return combinedStyles
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
module.exports = { getBrands3 }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getBlueconic } from "../../blueconic"
|
|
2
|
-
import {
|
|
2
|
+
import { getBrands3 } from "../../brands3"
|
|
3
3
|
import { appCheck, blendHDN } from "../../index"
|
|
4
4
|
|
|
5
5
|
/** Used for resizing the WCM Image */
|
|
@@ -51,7 +51,7 @@ function appendLayoutScripts(isEmbedded, isAdRemoved, marketKey) {
|
|
|
51
51
|
|
|
52
52
|
// Init sailthru
|
|
53
53
|
if (window && window.Sailthru && marketKey) {
|
|
54
|
-
window.Sailthru.init({ customerId:
|
|
54
|
+
window.Sailthru.init({ customerId: getBrands3(marketKey).attributes.sailCustomer })
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}, 5000)
|
|
@@ -59,7 +59,7 @@ function appendLayoutScripts(isEmbedded, isAdRemoved, marketKey) {
|
|
|
59
59
|
|
|
60
60
|
function formatHDN(isEmbedded, url_add, meta) {
|
|
61
61
|
const isApp = appCheck();
|
|
62
|
-
const thisBrand =
|
|
62
|
+
const thisBrand = getBrands3(meta.PROJECT.MARKET_KEY);
|
|
63
63
|
|
|
64
64
|
// Combine our settings with what Hearst puts on page
|
|
65
65
|
let stringHDN = ''
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from "react";
|
|
2
2
|
|
|
3
|
-
import { Helmet } from
|
|
4
|
-
import { appCheck, getBrands2 } from "../../index"
|
|
3
|
+
import { Helmet } from "react-helmet";
|
|
4
|
+
import { appCheck, getBrands2, getBrands3 } from "../../index";
|
|
5
5
|
|
|
6
|
-
const LayoutHelmet = ({
|
|
6
|
+
const LayoutHelmet = ({
|
|
7
|
+
meta,
|
|
8
|
+
url_add,
|
|
9
|
+
noindex = false,
|
|
10
|
+
schemaOverride = {},
|
|
11
|
+
brandsVer = 2,
|
|
12
|
+
}) => {
|
|
7
13
|
let {
|
|
8
14
|
EMBEDDED,
|
|
9
15
|
MAIN_DOMAIN,
|
|
@@ -21,69 +27,82 @@ const LayoutHelmet = ({ meta, url_add, noindex=false, schemaOverride={} }) => {
|
|
|
21
27
|
MARKET_KEY,
|
|
22
28
|
CANONICAL_URL,
|
|
23
29
|
ANALYTICS_CREDIT,
|
|
24
|
-
SECTION
|
|
30
|
+
SECTION,
|
|
25
31
|
},
|
|
26
|
-
} = meta
|
|
32
|
+
} = meta;
|
|
27
33
|
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
// Handle style sheet on brands2 vs brands3
|
|
35
|
+
const isApp = appCheck();
|
|
36
|
+
let styleSheetID;
|
|
37
|
+
let thisBrand;
|
|
38
|
+
if (brandsVer === 2) {
|
|
39
|
+
thisBrand = getBrands2(MARKET_KEY);
|
|
40
|
+
if (
|
|
41
|
+
MARKET_KEY === "SFC" ||
|
|
42
|
+
MARKET_KEY === "Houston" ||
|
|
43
|
+
MARKET_KEY === "Albany"
|
|
44
|
+
) {
|
|
45
|
+
styleSheetID = MARKET_KEY;
|
|
46
|
+
} else {
|
|
47
|
+
styleSheetID = "default";
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
thisBrand = getBrands3(MARKET_KEY);
|
|
51
|
+
if (MARKET_KEY === "SFC") {
|
|
52
|
+
styleSheetID = "plat-styles/" + MARKET_KEY;
|
|
53
|
+
} else {
|
|
54
|
+
styleSheetID = "plat-styles/default";
|
|
55
|
+
}
|
|
38
56
|
}
|
|
39
57
|
|
|
40
58
|
// Handle author data
|
|
41
|
-
let authorObj = []
|
|
42
|
-
let newAuthor = {}
|
|
59
|
+
let authorObj = [];
|
|
60
|
+
let newAuthor = {};
|
|
43
61
|
try {
|
|
44
|
-
if (!ANALYTICS_CREDIT){
|
|
62
|
+
if (!ANALYTICS_CREDIT) {
|
|
45
63
|
// If we have authors (not analytics credit), use those
|
|
46
|
-
AUTHORS.forEach(author => {
|
|
64
|
+
AUTHORS.forEach((author) => {
|
|
47
65
|
newAuthor = {
|
|
48
|
-
|
|
66
|
+
"@type": "Person",
|
|
49
67
|
name: author.AUTHOR_NAME,
|
|
50
68
|
url: author.AUTHOR_PAGE,
|
|
51
|
-
}
|
|
52
|
-
authorObj.push(newAuthor)
|
|
53
|
-
})
|
|
69
|
+
};
|
|
70
|
+
authorObj.push(newAuthor);
|
|
71
|
+
});
|
|
54
72
|
} else {
|
|
55
73
|
// If we have analytics credit, use that
|
|
56
|
-
const creditList = ANALYTICS_CREDIT.split(",")
|
|
57
|
-
creditList.forEach(credit => {
|
|
74
|
+
const creditList = ANALYTICS_CREDIT.split(",");
|
|
75
|
+
creditList.forEach((credit) => {
|
|
58
76
|
newAuthor = {
|
|
59
|
-
|
|
77
|
+
"@type": "Person",
|
|
60
78
|
name: credit,
|
|
61
|
-
url: MAIN_DOMAIN // Not ideal to not have the actual author page, but we don't have it
|
|
62
|
-
}
|
|
63
|
-
authorObj.push(newAuthor)
|
|
64
|
-
})
|
|
79
|
+
url: MAIN_DOMAIN, // Not ideal to not have the actual author page, but we don't have it
|
|
80
|
+
};
|
|
81
|
+
authorObj.push(newAuthor);
|
|
82
|
+
});
|
|
65
83
|
}
|
|
66
84
|
} catch (err) {
|
|
67
85
|
// If it errored, just set to neutral default
|
|
68
86
|
authorObj = {
|
|
69
|
-
|
|
87
|
+
"@type": "Person",
|
|
70
88
|
name: thisBrand.attributes.siteName,
|
|
71
89
|
url: MAIN_DOMAIN,
|
|
72
|
-
}
|
|
90
|
+
};
|
|
73
91
|
}
|
|
74
92
|
|
|
75
93
|
// Handle special favicon logic
|
|
76
|
-
let favHref = "/favicon.ico"
|
|
77
|
-
if (MARKET_KEY === "TK"){
|
|
78
|
-
favHref = "https://files.sfchronicle.com/devhub-logos/DHlogos-sm.png"
|
|
79
|
-
} else if (MARKET_KEY === "Seattle"){
|
|
80
|
-
favHref =
|
|
94
|
+
let favHref = "/favicon.ico";
|
|
95
|
+
if (MARKET_KEY === "TK") {
|
|
96
|
+
favHref = "https://files.sfchronicle.com/devhub-logos/DHlogos-sm.png";
|
|
97
|
+
} else if (MARKET_KEY === "Seattle") {
|
|
98
|
+
favHref =
|
|
99
|
+
"https://www.seattlepi.com/sites/seattlepi/apple-touch-icon-196x196.png";
|
|
81
100
|
}
|
|
82
101
|
|
|
83
102
|
// Set section with fallback
|
|
84
|
-
let articleSection = "Local"
|
|
103
|
+
let articleSection = "Local";
|
|
85
104
|
if (SECTION) {
|
|
86
|
-
articleSection = SECTION
|
|
105
|
+
articleSection = SECTION;
|
|
87
106
|
}
|
|
88
107
|
|
|
89
108
|
// Set the default schema that will be used as a fallback
|
|
@@ -114,21 +133,20 @@ const LayoutHelmet = ({ meta, url_add, noindex=false, schemaOverride={} }) => {
|
|
|
114
133
|
},
|
|
115
134
|
"articleSection": "${articleSection}",
|
|
116
135
|
"description": "${DESCRIPTION}"
|
|
117
|
-
}
|
|
136
|
+
}`;
|
|
118
137
|
|
|
119
138
|
return (
|
|
120
139
|
<Helmet>
|
|
121
140
|
<title>{TITLE}</title>
|
|
122
141
|
<meta name="description" content={DESCRIPTION} />
|
|
142
|
+
<link rel="shortcut icon" href={favHref} type="image/x-icon" />
|
|
143
|
+
<link rel="canonical" href={`${CANONICAL_URL}/${url_add}`} />
|
|
123
144
|
<link
|
|
124
|
-
rel="
|
|
125
|
-
href={
|
|
126
|
-
type="image/x-icon"
|
|
145
|
+
rel="stylesheet"
|
|
146
|
+
href={`https://files.sfchronicle.com/brand-styles/${styleSheetID}.css`}
|
|
127
147
|
/>
|
|
128
|
-
<link rel="canonical" href={`${CANONICAL_URL}/${url_add}`} />
|
|
129
|
-
<link rel="stylesheet" href={`https://files.sfchronicle.com/brand-styles/${styleSheetID}.css`} />
|
|
130
148
|
|
|
131
|
-
{
|
|
149
|
+
{isApp || EMBEDDED || noindex ? (
|
|
132
150
|
<meta name="robots" content="noindex, nofollow" />
|
|
133
151
|
) : (
|
|
134
152
|
<meta name="robots" content="max-image-preview:large" />
|
|
@@ -147,14 +165,21 @@ const LayoutHelmet = ({ meta, url_add, noindex=false, schemaOverride={} }) => {
|
|
|
147
165
|
<meta property="og:type" content="article" />
|
|
148
166
|
<meta property="og:title" content={SOCIAL_TITLE} />
|
|
149
167
|
<meta property="og:site_name" content={thisBrand.attributes.siteName} />
|
|
150
|
-
<meta
|
|
168
|
+
<meta
|
|
169
|
+
property="og:url"
|
|
170
|
+
content={`${MAIN_DOMAIN}/${SUBFOLDER}${OPT_SLASH}${SLUG}/${url_add}`}
|
|
171
|
+
/>
|
|
151
172
|
<meta property="og:image" content={IMAGE} />
|
|
152
173
|
<meta property="og:description" content={DESCRIPTION} />
|
|
153
174
|
|
|
154
|
-
<script
|
|
155
|
-
|
|
175
|
+
<script
|
|
176
|
+
data-schema={schemaOverride.type || "NewsArticle"}
|
|
177
|
+
type="application/ld+json"
|
|
178
|
+
>
|
|
179
|
+
{schemaOverride.content || schemaContent}
|
|
180
|
+
</script>
|
|
156
181
|
</Helmet>
|
|
157
|
-
)
|
|
158
|
-
}
|
|
182
|
+
);
|
|
183
|
+
};
|
|
159
184
|
|
|
160
|
-
export default LayoutHelmet
|
|
185
|
+
export default LayoutHelmet;
|
package/copy/sheets.js
CHANGED
|
@@ -12,9 +12,19 @@ var { google } = require("googleapis");
|
|
|
12
12
|
var api = google.sheets("v4");
|
|
13
13
|
var writeFile = require("write");
|
|
14
14
|
var authObj = require("./googleauth");
|
|
15
|
+
// Try to import story_settings.sheet.json
|
|
16
|
+
let languageSwap;
|
|
17
|
+
try {
|
|
18
|
+
const storySettings = require("../../../src/data/story_settings.sheet.json");
|
|
19
|
+
if (storySettings) {
|
|
20
|
+
languageSwap = storySettings[0].Language_Swap;
|
|
21
|
+
}
|
|
22
|
+
} catch (err) {
|
|
23
|
+
// It's ok
|
|
24
|
+
}
|
|
15
25
|
|
|
16
26
|
var cast = function (str, forceStr) {
|
|
17
|
-
if (!forceStr){
|
|
27
|
+
if (!forceStr) {
|
|
18
28
|
if (typeof str !== "string") {
|
|
19
29
|
if (typeof str.value == "string") {
|
|
20
30
|
str = str.value;
|
|
@@ -30,37 +40,45 @@ var cast = function (str, forceStr) {
|
|
|
30
40
|
if (str.toLowerCase() == "true" || str.toLowerCase() == "false") {
|
|
31
41
|
return str.toLowerCase() == "true" ? true : false;
|
|
32
42
|
}
|
|
33
|
-
}
|
|
43
|
+
}
|
|
34
44
|
// To force string, just return string
|
|
35
45
|
|
|
36
46
|
return str;
|
|
37
47
|
};
|
|
38
48
|
|
|
39
49
|
let googleAuth = (project, directory = null, forceStr = false) => {
|
|
40
|
-
return new Promise(resolveFinal => {
|
|
50
|
+
return new Promise((resolveFinal) => {
|
|
41
51
|
var auth = null;
|
|
42
|
-
authObj
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
authObj
|
|
53
|
+
.authenticate({ fallback: false })
|
|
54
|
+
.then((resp) => {
|
|
55
|
+
auth = resp;
|
|
56
|
+
grabSheets(auth, project, directory, forceStr)
|
|
57
|
+
.then(() => resolveFinal())
|
|
58
|
+
.catch(() => {
|
|
59
|
+
// If the first attempt failed, then make another req using the fallback
|
|
60
|
+
authObj.authenticate({ fallback: true }).then((resp) => {
|
|
61
|
+
auth = resp;
|
|
62
|
+
grabSheets(auth, project, directory, forceStr).then(() =>
|
|
63
|
+
resolveFinal()
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
})
|
|
68
|
+
.catch(() => {
|
|
69
|
+
// Failure if we fall back but there's no token
|
|
70
|
+
auth = authObj.task();
|
|
71
|
+
grabSheets(auth, project, directory, forceStr).then(() =>
|
|
72
|
+
resolveFinal()
|
|
73
|
+
);
|
|
50
74
|
});
|
|
51
|
-
|
|
52
|
-
.catch(() => {
|
|
53
|
-
// Failure if we fall back but there's no token
|
|
54
|
-
auth = authObj.task();
|
|
55
|
-
grabSheets(auth, project, directory, forceStr).then(() => resolveFinal());
|
|
56
|
-
});
|
|
57
|
-
})
|
|
75
|
+
});
|
|
58
76
|
};
|
|
59
77
|
|
|
60
78
|
let grabSheets = (auth, project, directory, forceStr) => {
|
|
61
79
|
return new Promise((resolveAll, rejectAll) => {
|
|
62
80
|
var sheetKeys = project.GOOGLE_SHEETS;
|
|
63
|
-
if (!sheetKeys){
|
|
81
|
+
if (!sheetKeys) {
|
|
64
82
|
// Try the old way
|
|
65
83
|
sheetKeys = project.sheets;
|
|
66
84
|
}
|
|
@@ -91,7 +109,14 @@ let grabSheets = (auth, project, directory, forceStr) => {
|
|
|
91
109
|
});
|
|
92
110
|
};
|
|
93
111
|
|
|
94
|
-
let getSheet = async (
|
|
112
|
+
let getSheet = async (
|
|
113
|
+
resolve,
|
|
114
|
+
reject,
|
|
115
|
+
auth,
|
|
116
|
+
spreadsheetId,
|
|
117
|
+
directory,
|
|
118
|
+
forceStr
|
|
119
|
+
) => {
|
|
95
120
|
let output = await api.spreadsheets
|
|
96
121
|
.get({
|
|
97
122
|
auth,
|
|
@@ -116,6 +141,20 @@ let getSheet = async (resolve, reject, auth, spreadsheetId, directory, forceStr)
|
|
|
116
141
|
});
|
|
117
142
|
var { values } = response.data;
|
|
118
143
|
var header = values.shift();
|
|
144
|
+
var swapIndexes = [];
|
|
145
|
+
if (languageSwap) {
|
|
146
|
+
for (var i = 0; i < header.length; i++) {
|
|
147
|
+
var lastIndex = header[i].lastIndexOf("_");
|
|
148
|
+
if (lastIndex > -1) {
|
|
149
|
+
// It has an underscore! Check for match
|
|
150
|
+
var substring = header[i].substring(lastIndex + 1).toLowerCase();
|
|
151
|
+
if (substring === languageSwap) {
|
|
152
|
+
// Match! Save the swap index
|
|
153
|
+
swapIndexes.push(i - 1);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
119
158
|
var isKeyed = header.indexOf("key") > -1;
|
|
120
159
|
var isValued = header.indexOf("value") > -1;
|
|
121
160
|
var out = isKeyed ? {} : [];
|
|
@@ -126,8 +165,20 @@ let getSheet = async (resolve, reject, auth, spreadsheetId, directory, forceStr)
|
|
|
126
165
|
var rowSkip = true;
|
|
127
166
|
row.forEach(function (value, i) {
|
|
128
167
|
var key = header[i];
|
|
168
|
+
// Handle language swap
|
|
169
|
+
if (swapIndexes.indexOf(i) > -1) {
|
|
170
|
+
// If we have a swap index, swap the value
|
|
171
|
+
// NOTE: This assumes the translation is ALWAYS one cell to the right
|
|
172
|
+
try {
|
|
173
|
+
if (row[i + 1]) {
|
|
174
|
+
value = row[i + 1];
|
|
175
|
+
}
|
|
176
|
+
} catch (err) {
|
|
177
|
+
// Not great but ok
|
|
178
|
+
}
|
|
179
|
+
}
|
|
129
180
|
obj[key] = cast(value, forceStr);
|
|
130
|
-
if (value && value !== "FALSE"){
|
|
181
|
+
if (value && value !== "FALSE") {
|
|
131
182
|
rowSkip = false;
|
|
132
183
|
}
|
|
133
184
|
});
|
package/css/nav2.less
CHANGED
package/example/gatsby-config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Add SFC utils
|
|
2
|
-
const {
|
|
2
|
+
const { getBrands3 } = require('../index')
|
|
3
3
|
const { getSettings } = require('./tempsettings')
|
|
4
4
|
const { DateTime } = require('luxon');
|
|
5
5
|
|
|
@@ -83,7 +83,7 @@ let plugins = [
|
|
|
83
83
|
resolve: 'gatsby-plugin-less',
|
|
84
84
|
options: {
|
|
85
85
|
lessOptions: {
|
|
86
|
-
modifyVars:
|
|
86
|
+
modifyVars: getBrands3(settings.PROJECT.MARKET_KEY).styles,
|
|
87
87
|
},
|
|
88
88
|
},
|
|
89
89
|
},
|
package/index.js
CHANGED
|
@@ -251,6 +251,7 @@ let blendHDN = function (meta) {
|
|
|
251
251
|
// Grab neighbor files
|
|
252
252
|
let { getBrands } = require("./brands");
|
|
253
253
|
let { getBrands2 } = require("./brands2");
|
|
254
|
+
let { getBrands3 } = require("./brands3");
|
|
254
255
|
let { getSettings } = require("./settings");
|
|
255
256
|
let { getNav } = require("./nav");
|
|
256
257
|
let { getNav2 } = require("./nav2");
|
|
@@ -266,6 +267,7 @@ module.exports = {
|
|
|
266
267
|
getSettings,
|
|
267
268
|
getBrands,
|
|
268
269
|
getBrands2,
|
|
270
|
+
getBrands3,
|
|
269
271
|
getNav,
|
|
270
272
|
getNav2,
|
|
271
273
|
getSpecialNav,
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ h1 {
|
|
|
21
21
|
//could the next three classes be moved into byline module?
|
|
22
22
|
.byline-wrapper {
|
|
23
23
|
max-width: @lg;
|
|
24
|
-
border-bottom: 1px solid @grey-
|
|
24
|
+
border-bottom: 1px solid @grey-25;
|
|
25
25
|
margin: @s16 auto @s24;
|
|
26
26
|
padding-bottom: @s8;
|
|
27
27
|
display: flex;
|
|
@@ -43,6 +43,10 @@ h1 {
|
|
|
43
43
|
font-weight: 700;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
.topper-dateline {
|
|
47
|
+
color: @grey-50;
|
|
48
|
+
}
|
|
49
|
+
|
|
46
50
|
.byline {
|
|
47
51
|
text-align: left;
|
|
48
52
|
display: inline-block;
|
|
@@ -214,7 +218,7 @@ h1 {
|
|
|
214
218
|
font-family: @sans;
|
|
215
219
|
font-size: @s14;
|
|
216
220
|
font-weight: 700;
|
|
217
|
-
color: @grey-
|
|
221
|
+
color: @grey-75;
|
|
218
222
|
}
|
|
219
223
|
|
|
220
224
|
@media @tablet {
|
|
@@ -223,7 +227,7 @@ h1 {
|
|
|
223
227
|
font-family: @sans;
|
|
224
228
|
font-size: @s14;
|
|
225
229
|
font-weight: 700;
|
|
226
|
-
color: @grey-
|
|
230
|
+
color: @grey-75;
|
|
227
231
|
}
|
|
228
232
|
}
|
|
229
233
|
}
|