-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-config.js
235 lines (224 loc) · 7 KB
/
gatsby-config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
require("dotenv").config({
path: `.env.production`,
})
const nodeIsIndex = (node, locale) => {
if (node.flamelink_locale != null) {
return node.flamelink_locale === locale
} else if (node.parent != null) {
return nodeIsIndex(node.parent, locale)
} else return false
}
const resolvePath = (node) => {
if (node.path) {
return node.path
} else {
const root = node.flamelink_locale === "no" ? "/" : "/en/"
const slug = node.slug
var path = slug
var parentListingPage = node.parentListingPage
while (parentListingPage != null) {
if (parentListingPage.slug != null) {
path = `${parentListingPage.slug}/${path}`
}
parentListingPage = parentListingPage.parentListingPage
}
return `${root}${path}`
}
}
module.exports = {
siteMetadata: {
title: `Trondheim.no`,
description: `Offisielt nettsted for Trondheim`,
author: `@trondheim`,
keywords: ["Trondheim"],
siteUrl: "https://www.trondheim.no/",
},
plugins: [
`gatsby-plugin-react-helmet`,
`gatsby-transformer-sharp`,
{
resolve: `gatsby-plugin-sharp`,
options: {
useMozJpeg: false,
stripMetadata: false,
defaultQuality: 90,
},
},
{
resolve: "gatsby-source-flamelink",
options: {
firebaseConfig: {
projectId: process.env.GATSBY_FLAMELINK_PROJECT_ID,
clientEmail: process.env.GATSBY_FLAMELINK_CLIENT_EMAIL,
privateKey: process.env.GATSBY_FLAMELINK_PRIVATE_KEY.replace(
/\\n/g,
"\n"
),
databaseURL: process.env.GATSBY_FLAMELINK_DATABASE_URL,
storageBucket: process.env.GATSBY_FLAMELINK_STORAGE_BUCKET,
},
content: [
{
schemaKey: "article",
populate: true,
filters: [
["_fl_meta_.status", "==", process.env.GATSBY_FLAMELINK_STATUS],
],
},
{
schemaKey: "studentArticle",
populate: true,
filters: [
["_fl_meta_.status", "==", process.env.GATSBY_FLAMELINK_STATUS],
],
},
{
schemaKey: "page",
populate: true,
filters: [
["_fl_meta_.status", "==", process.env.GATSBY_FLAMELINK_STATUS],
],
},
{ schemaKey: "articleLocalization", populate: true },
{ schemaKey: "copyright", populate: true },
{ schemaKey: "defaultThumbnails", populate: true },
{ schemaKey: "frontPage", populate: true },
{ schemaKey: "layoutLocalization", populate: true },
{ schemaKey: "listingPage", populate: true },
{ schemaKey: "studentListingPage", populate: true },
{ schemaKey: "listingPageLocalization", populate: true },
{ schemaKey: "navbar", populate: true },
{ schemaKey: "seo", populate: true },
{ schemaKey: "studentPage", populate: true },
{ schemaKey: "aboutStudyTrondheim", populate: true },
],
dbType: "cf",
environment: "production",
navigation: true,
globals: true,
},
},
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `Offisielt nettsted for Trondheim`,
short_name: `Trondheim.no`,
start_url: `/`,
lang: `no`,
background_color: `#f7f0eb`,
theme_color: `#000000`,
display: `standalone`,
scope: "/",
cache_busting_mode: "none",
icons: [
{
src: `images/logo192.png`,
sizes: `192x192`,
type: `image/png`,
},
{
src: `images/logo512.png`,
sizes: `512x512`,
type: `image/png`,
},
],
localize: [
{
start_url: `/en/`,
lang: `en-US`,
name: `The official website for Trondheim`,
short_name: `Trondheim.no`,
},
],
},
},
{
resolve: `gatsby-plugin-offline`,
options: {
precachePages: [
"/",
"/en",
"/hoteller/**/*",
"/en/hotels/**/*",
"/shopping/**/*",
"/en/shopping-areas/**/*",
"/severdig/**/*",
"/en/attractions/**/*",
"/spisesteder/**/*",
"/en/restaurants/**/*",
"/ut-pa-tur/**/*",
"/en/hiking-and-walks/**/*",
],
},
},
{
resolve: `gatsby-plugin-lunr`,
options: {
languages: [
{
// ISO 639-1 language codes. See https://lunrjs.com/guides/language_support.html for details
name: "no",
// A function for filtering nodes. () => true by default
filterNodes: (node) => nodeIsIndex(node, "no"),
// Add to index custom entries, that are not actually extracted from gatsby nodes
customEntries: [],
},
{
// ISO 639-1 language codes. See https://lunrjs.com/guides/language_support.html for details
name: "en",
// A function for filtering nodes. () => true by default
filterNodes: (node) => nodeIsIndex(node, "en-US"),
// Add to index custom entries, that are not actually extracted from gatsby nodes
customEntries: [],
},
],
// Fields to index. If store === true value will be stored in index file.
// Attributes for custom indexing logic. See https://lunrjs.com/docs/lunr.Builder.html for details
fields: [
{ name: "title", store: true, attributes: { boost: 20 } },
{ name: "content", store: true },
{ name: "url", store: true },
],
// How to resolve each field's value for a supported node type
resolvers: {
FlamelinkPageContent: {
title: (node) => node.title,
content: (node) => node.fields.textContent,
url: (node) => resolvePath(node),
},
FlamelinkListingPageContent: {
title: (node) => node.localTitle,
content: (node) => node.textOnPage,
url: (node) => resolvePath(node),
},
FlamelinkArticleContent: {
title: (node) => node.title,
content: (node) => node.fields.textContent,
url: (node) => resolvePath(node),
},
},
//custom index file name, default is search_index.json
filename: "search_index.json",
//custom options on fetch api call for search_ındex.json
fetchOptions: {
credentials: "same-origin",
},
},
},
{
resolve: `gatsby-plugin-sitemap`,
options: {
//exclude url from appearing in search results
exclude: ["/search", "/en/search", "/en/404"],
},
},
{
resolve: "gatsby-plugin-robots-txt",
options: {
host: "https://www.trondheim.no/",
sitemap: "https://www.trondheim.no/sitemap.xml",
policy: [{ userAgent: "*", allow: "/*" }],
},
},
],
}