-
Notifications
You must be signed in to change notification settings - Fork 14
/
next.config.js
160 lines (149 loc) · 4.03 KB
/
next.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
/* eslint-disable @typescript-eslint/no-var-requires */
const flow = require('lodash.flow');
const withManifest = require('next-manifest');
const withOffline = require('next-offline');
const algoliasearch = require('algoliasearch');
require('dotenv').config();
const INDEX_HITS_PER_PAGE = 1000;
const exportPathMap = async function () {
const pages = {
'/': {
page: '/',
query: {
vse: ''
}
},
'/preview': {
page: '/preview',
query: {
content: '',
vse: ''
}
},
'/visualization.html': {
page: '/visualization',
query: {
vse: '',
content: ''
}
}
};
const client = algoliasearch(process.env.ALGOLIA_APPLICATION_ID, process.env.SEARCH_API_KEY);
const index = client.initIndex(process.env.SEARCH_INDEX_NAME_PRODUCTION);
try {
console.info('\nLoading blog posts:');
const results = await index.search('', {
attributesToRetrieve: ['objectID', 'deliveryKey'],
attributesToHighlight: [],
hitsPerPage: INDEX_HITS_PER_PAGE
});
results.hits.forEach(blogPost => {
if (!blogPost.deliveryKey) {
console.warn('No deliveryKey for blogPost', blogPost);
}
const slug = blogPost.deliveryKey ? blogPost.deliveryKey : blogPost.objectID;
const path = `/blog/${encodeURIComponent(slug)}`;
const pageInfo = {
page: '/blog/[...slug]',
query: { slug }
};
console.info(`Loading blog post "${path}`, pageInfo);
pages[path] = pageInfo;
});
} catch (err) {
console.error('Error building exportPathMap', err);
throw err;
}
return pages;
};
const env = {
URL: process.env.URL,
ALGOLIA_APPLICATION_ID: process.env.ALGOLIA_APPLICATION_ID,
SEARCH_API_KEY: process.env.SEARCH_API_KEY,
SEARCH_INDEX_NAME_PRODUCTION: process.env.SEARCH_INDEX_NAME_PRODUCTION,
SEARCH_INDEX_NAME_STAGING: process.env.SEARCH_INDEX_NAME_STAGING,
AUTHORS_FACET_FIELD: process.env.AUTHORS_FACET_FIELD,
DYNAMIC_CONTENT_HUB_NAME: process.env.DYNAMIC_CONTENT_HUB_NAME,
DYNAMIC_CONTENT_DELIVERY_KEY: process.env.DYNAMIC_CONTENT_DELIVERY_KEY,
DYNAMIC_CONTENT_BASE_URL: process.env.DYNAMIC_CONTENT_BASE_URL,
DYNAMIC_CONTENT_SECURE_MEDIA_HOST: process.env.DYNAMIC_CONTENT_SECURE_MEDIA_HOST,
ROBOTS_META_TAG_NOINDEX: process.env.ROBOTS_META_TAG_NOINDEX || 'true',
TAGS_FACET_FIELD: process.env.TAGS_FACET_FIELD,
HITS_PER_PAGE: process.env.HITS_PER_PAGE
};
const manifest = {
name: 'Amplience Product Blog',
short_name: 'Amplience',
theme_color: '#29333f',
background_color: '#29333f',
display: 'standalone',
orientation: 'portrait',
Scope: '/',
start_url: '/',
cache: true,
output: './public/static/',
icons: [
{
src: '/static/icons/icon-72x72.png',
sizes: '72x72',
type: 'image/png'
},
{
src: '/static/icons/icon-96x96.png',
sizes: '96x96',
type: 'image/png'
},
{
src: '/static/icons/icon-128x128.png',
sizes: '128x128',
type: 'image/png'
},
{
src: '/static/icons/icon-144x144.png',
sizes: '144x144',
type: 'image/png'
},
{
src: '/static/icons/icon-152x152.png',
sizes: '152x152',
type: 'image/png'
},
{
src: '/static/icons/icon-192x192.png',
sizes: '192x192',
type: 'image/png'
},
{
src: '/static/icons/icon-384x384.png',
sizes: '384x384',
type: 'image/png'
},
{
src: '/static/icons/icon-512x512.png',
sizes: '512x512',
type: 'image/png'
}
],
splash_pages: null
};
const plugins = [withManifest];
// the withOffline plugin doesn't work with the nextjs-sitemap-generator,
// so if SITEMAP_GENERATOR is present skip the withOffline plugin
if (!process.env.SITEMAP_GENERATOR) {
plugins.push(withOffline);
}
const invokePlugins = flow(plugins);
module.exports = invokePlugins({
env,
exportPathMap,
manifest,
exportTrailingSlash: true,
workboxOpts: {
runtimeCaching: [
{
urlPattern: /.mp4$/,
handler: 'NetworkFirst'
}
]
}
});