This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgatsby-node.js
64 lines (56 loc) · 1.74 KB
/
gatsby-node.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
require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`,
})
const path = require('path');
const axios = require('axios');
exports.createPages = async ({ actions: { createPage } }) => {
const { data: themes } = await axios.get(`${process.env.GATSBY_API_URL}/metastore/schemas/theme/items`);
const { data: datasets } = await axios.get(`${process.env.GATSBY_API_URL}/metastore/schemas/dataset/items?show-reference-ids`);
let featuredDatasets = datasets.sort(function(a,b) {
return a.title - b.title;
});
featuredDatasets = featuredDatasets.length > 3 ? featuredDatasets.slice(featuredDatasets.length -3, featuredDatasets.length) : featuredDatasets;
createPage({
path: `/`,
component: path.resolve('./src/templates/home/index.js'),
context: { themes, featuredDatasets }
});
createPage({
path: `/search`,
component: path.resolve('./src/templates/search/index.jsx')
});
datasets.map((dataset) => {
createPage({
path: `/dataset/${dataset.identifier}`,
component: path.resolve('./src/templates/dataset/index.jsx'),
context: { dataset }
})
createPage({
path: `/dataset/${dataset.identifier}/api`,
component: path.resolve('./src/templates/dataset/api.js'),
context: { dataset }
})
})
}
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
if (stage === "build-html") {
actions.setWebpackConfig({
module: {
rules: [
{
test: /react-loader-advanced/,
use: loaders.null(),
},
{
test: /react-loading-spin/,
use: loaders.null(),
},
{
test: /swagger-ui-react/,
use: loaders.null(),
},
],
},
})
}
}