@@ -136,105 +136,154 @@ The worker we have setup will run on our assigned route, but it will just return
136
136
</tr>
137
137
</thead >
138
138
<tbody >
139
- <tr>
140
- <td><code>contentType</code></td>
141
- <td>String[]</td>
142
- <td><code>['text/html']</code></td>
143
- <td>Example: ['text/html', 'text/css']</td>
144
- <td>Defines the content types that should be processed</td>
145
- </tr>
146
- <tr>
147
- <td><code>ignoreRoutes</code></td>
148
- <td>String[]</td>
149
- <td><code>[]</code></td>
150
- <td>Example: ['/wp-admin', '/assets/js']</td>
151
- <td>A list of routes where grid-aware code should not be applied</td>
152
- </tr>
153
- <tr>
154
- <td><code>ignoreGawCookie</code></td>
155
- <td>String</td>
156
- <td><code>'gaw-ignore'</code></td>
157
- <td>"gaw-ignore"</td>
158
- <td>A cookie that when present will result in grid-aware code being skipped</td>
159
- </tr>
160
- <tr>
161
- <td><code>locationType</code></td>
162
- <td>String</td>
163
- <td><code>'country'</code></td>
164
- <td>"country", "latlon"</td>
165
- <td>Indicates the geolocation data to use for grid-aware checks.</td>
166
- </tr>
167
- <tr>
168
- <td><code>htmlChanges</code></td>
169
- <td>HTMLRewriter</td>
170
- <td><code>null</code></td>
171
- <td>See code example below</td>
172
- <td>HTMLRewriter functions which can be used to make adjustments to the page when grid-aware changes need to be appplied.</td>
173
- </tr>
174
- <tr>
175
- <td><code>gawDataSource</code></td>
176
- <td>String</td>
177
- <td><code>'electricity maps'</code></td>
178
- <td>"electricity maps"</td>
179
- <td>The data source to use from the core Grid-aware Websites library.</td>
180
- </tr>
181
- <tr>
182
- <td><code>gawDataApiKey</code></td>
183
- <td>String</td>
184
- <td><code>''</code></td>
185
- <td>"xyz123"</td>
186
- <td>The API key (if any) for the chosen data source.</td>
187
- </tr>
188
- <tr>
189
- <td><code>gawDataType</code></td>
190
- <td>String</td>
191
- <td><code>'power'</code></td>
192
- <td>"power", "carbon"</td>
193
- <td>The data type to use from the core Grid-aware Websites library.</td>
194
- </tr>
195
- <tr>
196
- <td><code>kvCacheData</code></td>
197
- <td>Boolean</td>
198
- <td><code>false</code></td>
199
- <td>true, false</td>
200
- <td>Indicate if grid data from the API should be cached in Cloudflare Workers KV for one hour.</td>
201
- </tr>
202
- <tr>
203
- <td><code>kvCachePage</code></td>
204
- <td>Boolean</td>
205
- <td><code>false</code></td>
206
- <td>true, false</td>
207
- <td>Indicates if the modified grid-aware page should be cached in Cloudflare Workers KV for 24 hours.</td>
208
- </tr>
209
- <tr>
210
- <td><code>debug</code></td>
211
- <td>String</td>
212
- <td>"none"</td>
213
- <td>"none", "full", "headers", "logs"</td>
214
- <td>Activates debug mode which outputs logs and returns additional response headers.</td>
215
- </tr>
216
- <tr>
217
- <td><code>dev</code></td>
218
- <td>Boolean</td>
219
- <td><code>false</code></td>
220
- <td>true, false</td>
221
- <td>Enables development mode, which redirects requests to a local development server. </td>
222
- </tr>
223
- <tr>
224
- <td><code>devConfig</code></td>
225
- <td>Object</td>
226
- <td><code>{}</code></td>
227
- <td><code>{hostname: "localhost", port: "8080", protocol: "http"}</code></td>
228
- <td>Configuration options for the development mode, including hostname, port, and protocol.</td>
229
- </tr>
230
- <tr>
231
- <td><code>infoBarTarget</code></td>
232
- <td>String</td>
233
- <td>''</td>
234
- <td>Example: "header", "#info-container"</td>
235
- <td>CSS selector for the element where the <a href="https://github.com/thegreenwebfoundation/gaw-web-component">grid-aware info bar</a> will be inserted.</td>
236
- </tr>
237
- </tbody >
139
+ <tr>
140
+ <td><code>contentType</code></td>
141
+ <td>String[]</td>
142
+ <td><code>['text/html']</code></td>
143
+ <td>Example: ['text/html', 'text/css']</td>
144
+ <td>Defines the content types that should be processed</td>
145
+ </tr>
146
+ <tr>
147
+ <td><code>ignoreRoutes</code></td>
148
+ <td>String[]</td>
149
+ <td><code>[]</code></td>
150
+ <td>Example: ['/wp-admin', '/assets/js']</td>
151
+ <td>A list of routes where grid-aware code should not be applied</td>
152
+ </tr>
153
+ <tr>
154
+ <td><code>ignoreGawCookie</code></td>
155
+ <td>String</td>
156
+ <td><code>'gaw-ignore'</code></td>
157
+ <td>"gaw-ignore"</td>
158
+ <td>A cookie that when present will result in grid-aware code being skipped</td>
159
+ </tr>
160
+ <tr>
161
+ <td><code>userOptIn</code></td>
162
+ <td>Boolean</td>
163
+ <td><code>false</code></td>
164
+ <td>true, false</td>
165
+ <td>Allows developers to specify if users are required to opt-in to the grid-aware website experience</td>
166
+ </tr>
167
+ <tr>
168
+ <td><code>locationType</code></td>
169
+ <td>String</td>
170
+ <td><code>'latlon'</code></td>
171
+ <td>"latlon", "country"</td>
172
+ <td>Type of ___location data to use</td>
173
+ </tr>
174
+ <tr>
175
+ <td><code>htmlChanges</code></td>
176
+ <td>Object</td>
177
+ <td>{}</td>
178
+ <td>{"low": HTMLRewriter, "moderate": HTMLRewriter, "high": HTMLRewriter}</td>
179
+ <td>An object to capture the different HTML changes that are applied at each different grid intesity level</td>
180
+ </tr>
181
+ <tr>
182
+ <td><code>htmlChanges.low</code></td>
183
+ <td>HTMLRewriter</td>
184
+ <td>null</td>
185
+ <td>Custom HTMLRewriter for page modification at low grid intensity level</td>
186
+ <td></td>
187
+ </tr>
188
+ <tr>
189
+ <td><code>htmlChanges.moderate</code></td>
190
+ <td>HTMLRewriter</td>
191
+ <td>null</td>
192
+ <td>Custom HTMLRewriter for page modification at moderate grid intensity level</td>
193
+ <td></td>
194
+ </tr>
195
+ <tr>
196
+ <td><code>htmlChanges.high</code></td>
197
+ <td>HTMLRewriter</td>
198
+ <td>null</td>
199
+ <td>Custom HTMLRewriter for page modification at high grid intensity level</td>
200
+ <td></td>
201
+ </tr>
202
+ <tr>
203
+ <td><code>defaultView</code></td>
204
+ <td>String/null</td>
205
+ <td><code>null</code></td>
206
+ <td>null, "low", "moderate", "high"</td>
207
+ <td>Default view for the grid-aware website experience</td>
208
+ </tr>
209
+ <tr>
210
+ <td><code>gawDataApiKey</code></td>
211
+ <td>String</td>
212
+ <td><code>''</code></td>
213
+ <td>"xyz123"</td>
214
+ <td>API key for the data source</td>
215
+ </tr>
216
+ <tr>
217
+ <td><code>infoBar</code></td>
218
+ <td>Object</td>
219
+ <td><code>{}</code></td>
220
+ <td><code>{target: "", version: "latest", learnMoreLink: "#", popoverText: ""}</code></td>
221
+ <td>Configuration for the info bar element</td>
222
+ </tr>
223
+ <tr>
224
+ <td><code>infoBar.target</code></td>
225
+ <td>String</td>
226
+ <td><code>''</code></td>
227
+ <td>Example: "header", "#info-container"</td>
228
+ <td>Target element for the info bar</td>
229
+ </tr>
230
+ <tr>
231
+ <td><code>infoBar.version</code></td>
232
+ <td>String</td>
233
+ <td><code>'latest'</code></td>
234
+ <td>"latest", "1.0.0"</td>
235
+ <td>Version of the info bar to use</td>
236
+ </tr>
237
+ <tr>
238
+ <td><code>infoBar.learnMoreLink</code></td>
239
+ <td>String</td>
240
+ <td><code>'#'</code></td>
241
+ <td>Example: "https://example.com/learn-more"</td>
242
+ <td>Link to learn more about the info bar</td>
243
+ </tr>
244
+ <tr>
245
+ <td><code>infoBar.popoverText</code></td>
246
+ <td>String</td>
247
+ <td><code>''</code></td>
248
+ <td>Example: "This website adapts based on carbon intensity"</td>
249
+ <td>Provide a custom string of text to be used in the info bar popover element</td>
250
+ </tr>
251
+ <tr>
252
+ <td><code>kvCacheData</code></td>
253
+ <td>Boolean</td>
254
+ <td><code>false</code></td>
255
+ <td>true, false</td>
256
+ <td>Whether to cache grid data in KV store. Read <a href="#cache-grid-data-in-cloudflare-workers-kv">setup instructions</a></td>
257
+ </tr>
258
+ <tr>
259
+ <td><code>kvCachePage</code></td>
260
+ <td>Boolean</td>
261
+ <td><code>false</code></td>
262
+ <td>true, false</td>
263
+ <td>Whether to cache modified pages in KV store. Read <a href="#cache-grid-data-in-cloudflare-workers-kv">setup instructions</a></td>
264
+ </tr>
265
+ <tr>
266
+ <td><code>debug</code></td>
267
+ <td>String</td>
268
+ <td>"none"</td>
269
+ <td>"none", "full", "headers", "logs"</td>
270
+ <td>Activates debug mode which outputs logs and returns additional response headers</td>
271
+ </tr>
272
+ <tr>
273
+ <td><code>dev</code></td>
274
+ <td>Boolean</td>
275
+ <td><code>false</code></td>
276
+ <td>true, false</td>
277
+ <td>Whether to enable development mode</td>
278
+ </tr>
279
+ <tr>
280
+ <td><code>devConfig</code></td>
281
+ <td>Object</td>
282
+ <td><code>{}</code></td>
283
+ <td><code>{hostname: "localhost", port: "8080", protocol: "http"}</code></td>
284
+ <td>Configuration for development mode</td>
285
+ </tr>
286
+ </tbody >
238
287
</table >
239
288
</div >
240
289
@@ -249,7 +298,14 @@ export default {
249
298
// Use this API key that has been saved as a secret
250
299
gawDataApiKey: env .EMAPS_API_KEY ,
251
300
// A CSS selector for the element where the grid-aware info bar will be inserted.
252
- infoBarTarget: " #gaw-info-bar" ,
301
+ infoBar: {
302
+ target: " #gaw-info-bar" ,
303
+ learnMoreLink:
304
+ " https://www.thegreenwebfoundation.org/tools/grid-aware-websites/" ,
305
+ version: " latest" ,
306
+ popoverText:
307
+ " This website adapts based on your local electricity grid's carbon intensity" ,
308
+ },
253
309
debug: " full" ,
254
310
// Make these changes to the web page using HTMLRewriter
255
311
htmlChanges: new HTMLRewriter ().on (" html" , {
0 commit comments