forked from c29r3/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
108 lines (97 loc) · 3.04 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
const path = require("path");
const { createClient } = require("contentful");
const withMDX = require("@next/mdx")({
options: {
remarkPlugins: [require("remark-slug")],
rehypePlugins: [[require("rehype-highlight"), { subset: false }]],
},
});
const withTM = require("next-transpile-modules");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
const SPACE = process.env.CONTENTFUL_SPACE || "37811siqosrn";
const TOKEN =
process.env.CONTENTFUL_TOKEN || "gONaARVCc0G5FLIkoJ2m4qi9yTpT8oi7u-C6VYxQ6UQ";
const IMAGE_TOKEN =
process.env.CONTENTFUL_IMAGE_TOKEN ||
"3B4LS4VD0c4RCsUl1rxmmX/d8ba4bd5295e3b65569cbda1329e90a6";
const CONTENTFUL_HOST = process.env.CONTENTFUL_HOST || "cdn.contentful.com";
const GOOGLE_API_KEY =
process.env.GOOGLE_API_KEY || "AIzaSyDIFwMr7SPGCLl_o6e4UZKi1q9l8snkUZs";
const blogType = "test";
const client = createClient({
accessToken: TOKEN,
space: SPACE,
host: CONTENTFUL_HOST,
});
module.exports = withTM(
withBundleAnalyzer(
withMDX({
async exportPathMap(pages) {
let blogPosts = await client.getEntries({
include: 0,
content_type: blogType,
});
let jobPosts = await client.getEntries({
include: 0,
content_type: "jobPost",
});
let announcementPosts = await client.getEntries({
include: 0,
content_type: "announcement",
});
// Add versions with trailing slash for backwards compatibility
pages["/blog/"] = { page: "/blog" };
pages["/announcements/"] = { page: "/announcements" };
blogPosts.items.forEach(({ fields: { slug } }) => {
pages["/blog/" + slug] = {
page: "/blog/[slug]",
query: { slug: slug },
};
// Add .html for backwards compatibility
pages["/blog/" + slug + ".html"] = {
page: "/blog/[slug]",
query: { slug: slug },
};
});
announcementPosts.items.forEach(({ fields: { slug } }) => {
pages["/announcements/" + slug] = {
page: "/announcements/[slug]",
query: { slug: slug },
};
// Add .html for backwards compatibility
pages["/announcements/" + slug + ".html"] = {
page: "/announcements/[slug]",
query: { slug: slug },
};
});
return pages;
},
pageExtensions: ["jsx", "js", "mdx"],
transpileModules: [
"bs-platform",
"bs-css",
"bsc-stdlib-polyfill",
"bs-fetch",
],
webpack(config, options) {
config.resolve.alias["@reason"] = path.join(
__dirname,
"lib",
"es6",
"src"
);
config.resolve.extensions.push(".bs.js");
return config;
},
env: {
CONTENTFUL_TOKEN: TOKEN,
CONTENTFUL_IMAGE_TOKEN: IMAGE_TOKEN,
CONTENTFUL_SPACE: SPACE,
CONTENTFUL_HOST: CONTENTFUL_HOST,
GOOGLE_API_KEY: GOOGLE_API_KEY,
},
})
)
);