-
Notifications
You must be signed in to change notification settings - Fork 1
/
gatsby-node.ts
52 lines (49 loc) · 1.59 KB
/
gatsby-node.ts
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
import { GatsbyNode } from 'gatsby';
import edizioniData from './src/utilities/edizioniData';
import { resolve } from 'path';
export const createPages: GatsbyNode['createPages'] = async ({ graphql, actions, reporter }) => {
const { createPage } = actions;
// you'll call `createPage` for each result
edizioniData.forEach((data) => {
createPage({
// As mentioned above you could also query something else like frontmatter.title above and use a helper function
// like slugify to create a slug
path: `/edizioni/${data.year}`,
// Provide the path to the MDX content file so webpack can pick it up and transform it into JSX
component: resolve(__dirname, 'src/templates/Edizioni/index.tsx'),
// You can use the values in this context in
// our page layout component
context: { ...data },
});
});
};
export const createSchemaCustomization: GatsbyNode['createSchemaCustomization'] = ({ stage, loaders, actions }) => {
const { createTypes } = actions;
createTypes(`
type SitePage implements Node {
context: SitePageContext
}
type SitePageContext {
i18n: i18nContext
}
type i18nContext {
language: String,
languages: [String],
defaultLanguage: String,
originalPath: String
routed: Boolean
}
`);
// if (stage === 'build-html' || stage === 'develop-html') {
// actions.setWebpackConfig({
// module: {
// rules: [
// {
// test: /react-p5/,
// use: (loaders as any).null(),
// },
// ],
// },
// });
// }
};