-
Notifications
You must be signed in to change notification settings - Fork 11
/
gatsby-node.ts
38 lines (33 loc) · 999 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 { NodePluginArgs } from 'gatsby';
import { PortfolioItemEntry } from './bcms/types';
import { getBcmsMost } from 'gatsby-source-bcms';
import path from 'path';
exports.createSchemaCustomization = ({ actions }: NodePluginArgs) => {
const { createTypes } = actions;
const typeDefs = `
scalar Number
`;
createTypes(typeDefs);
};
exports.createPages = async ({ actions }: any) => {
const { createPage } = actions;
// SINGLE portfolio PAGES
const PortfolioTemplate = path.resolve('./src/templates/portfolio.tsx');
const bcms = getBcmsMost();
const portfolios = (await bcms.content.entry.find(
'portfolio_item',
async () => true,
)) as PortfolioItemEntry[];
if (portfolios.length > 0) {
portfolios.forEach((portfolio) => {
createPage({
path: `/portfolio/${portfolio.meta.en?.slug}`,
component: PortfolioTemplate,
context: {
id: portfolio._id,
},
});
});
}
// END OF SINGLE portfolio PAGES
};