-
Notifications
You must be signed in to change notification settings - Fork 4
/
gatsby-node.js
110 lines (104 loc) · 2.67 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
const fs = require("fs");
const _ = require("lodash");
const got = require("got");
exports.onPreExtractQueries = async () => {
let response;
const requestOptions = {
json: {
sid: process.env.OBERION_SITE_ID,
key: process.env.OBERION_API_KEY,
},
};
try {
response = await got.post(process.env.OBERION_API_ENDPOINT, requestOptions).json();
} catch (error) {
console.error("Error while fetching site data", error);
let body = {};
// if (error instanceof got.HTTPError) body = await error.response.json();
// console.error("", error, { ...requestOptions.json, ...body });
process.exit(1);
}
const siteData = _.get(response, "data.siteData", null);
// console.log("siteData", siteData);
if (siteData === null) {
console.error(`error retrieving siteData`, response);
process.exit(1);
}
try {
await fs.writeFileSync("./res/site-data.json", JSON.stringify(siteData));
} catch (err) {
console.error(`Error while saving your site data. Make sure the target directory exists.`, err);
process.exit(1);
}
};
/**
* Create explicit GraphQL type definitions to provide the right types.
* @see https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions
*/
exports.createSchemaCustomization = ({ actions }) => {
const { createTypes } = actions;
const typeDefs = `
type siteData implements Node @dontInfer {
appid: ID
gameName: String
description: String
movies: [Movies]
screenshots: [Screenshots]
legalNoticeSteam: String
supportInfo: SupportInfo
legal: Legal
socialMedia: SocialMedia
images: Images
}
type Screenshots {
screenshotID: ID
path_thumbnail: String
path_full: String
}
type SupportInfo {
url: String
email: String
}
type Movies {
movieID: ID
name: String
thumbnail: String
webm: Webm
mp4: Mp4
highlight: Boolean
}
type Webm {
res480: String
resMax: String
}
type Mp4 {
res480: String
resMax: String
}
type Legal {
studioName: String
contact: String
legalNotice: String
}
type SocialMedia {
discord: String
facebook: String
instagram: String
reddit: String
twitter: String
youtube: String
twitch: String
}
type Images {
hero: String
logoGame: String
}
`;
createTypes(typeDefs);
};
/** Fix React hot loader warning */
exports.onCreateWebpackConfig = ({ stage, actions }) => {
if (stage.startsWith("develop")) {
actions.setWebpackConfig({ resolve: { alias: { "react-dom": "@hot-loader/react-dom" } } });
}
};