-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
53 lines (42 loc) · 1.91 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
const indexSearch = require('./plugins/search-index');
const feed = require('./plugins/feed');
const sitemap = require('./plugins/sitemap');
// const socialImages = require('./plugins/socialImages'); TODO: failing to run on Netlify
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
// By default, Next.js removes the trailing slash. One reason this would be good
// to include is by default, the `path` property of the router for the homepage
// is `/` and by using that, would instantly create a redirect
trailingSlash: true,
// By enabling verbose logging, it will provide additional output details for
// diagnostic purposes. By default is set to false.
// verbose: true,
env: {
// The image directory for open graph images will be saved at the location above
// with `public` prepended. By default, images will be saved at /public/images/og
// and available at /images/og. If changing, make sure to update the .gitignore
OG_IMAGE_DIRECTORY: '/images/og',
// By default, only render this number of post pages ahead of time, otherwise
// the rest will be rendered on-demand
POSTS_PRERENDER_COUNT: 5,
WORDPRESS_GRAPHQL_ENDPOINT: process.env.WORDPRESS_GRAPHQL_ENDPOINT,
WORDPRESS_MENU_LOCATION_NAVIGATION: process.env.WORDPRESS_MENU_LOCATION_NAVIGATION || 'PRIMARY',
WORDPRESS_PLUGIN_SEO: parseEnvValue(process.env.WORDPRESS_PLUGIN_SEO, false),
},
};
module.exports = () => {
const plugins = [indexSearch, feed, sitemap];
return plugins.reduce((acc, plugin) => plugin(acc), nextConfig);
};
/**
* parseEnv
* @description Helper function to check if a variable is defined and parse booelans
*/
function parseEnvValue(value, defaultValue) {
if (typeof value === 'undefined') return defaultValue;
if (value === true || value === 'true') return true;
if (value === false || value === 'false') return false;
return value;
}