This repository has been archived by the owner on Jun 6, 2024. It is now read-only.
forked from GetDKAN/data-catalog-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-node.js
87 lines (76 loc) · 2.29 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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.js'),
context: { themes }
});
datasets.map((dataset) => {
createPage({
path: `/dataset/${dataset.identifier}`,
component: path.resolve('./src/templates/dataset/index.js'),
context: { dataset }
})
createPage({
path: `/dataset/${dataset.identifier}/api`,
component: path.resolve('./src/templates/dataset/api.js'),
context: { dataset }
})
})
// await Promise.all(jsonData.map(data => {
// return new Promise((resolve, reject) => {
// axios.get(`http://dkan/api/v1/datastore/${data.identifier}?values=both`)
// .then(function (response) {
// // handle success
// resolve(response.data);
// })
// .catch(function (error) {
// // handle error
// resolve(data);
// })
// });
// }))
// .then(results => {
// results.forEach((dataset) => {
// createPage({
// });
// })
// })
}
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(),
},
],
},
})
}
}