-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-node.ts
38 lines (35 loc) · 885 Bytes
/
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
import type { GatsbyNode } from 'gatsby';
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
const path = require(`path`);
export const onCreateWebpackConfig: GatsbyNode['onCreateWebpackConfig'] = ({
actions,
}) => {
actions.setWebpackConfig({
resolve: {
plugins: [new TsconfigPathsPlugin()],
},
});
};
exports.createPages = async ({ graphql, actions }) => {
const { data } = await graphql(`
query Projects {
allMarkdownRemark {
edges {
node {
frontmatter {
slug
}
}
}
}
}
`);
data.allMarkdownRemark.edges.forEach((edge) => {
const slug = edge.node.frontmatter.slug;
actions.createPage({
path: '/portfolio/' + slug,
component: path.resolve('./src/templates/project-details.jsx'),
context: { slug: slug },
});
});
};