Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Gustafsson committed Mar 4, 2021
1 parent ce316dd commit 164896d
Show file tree
Hide file tree
Showing 15 changed files with 198 additions and 24,804 deletions.
14 changes: 0 additions & 14 deletions apollo.config.js

This file was deleted.

12 changes: 0 additions & 12 deletions codegen.yml

This file was deleted.

20 changes: 0 additions & 20 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,6 @@ module.exports = {
author: `@hi3g Sweden`,
},
plugins: [
{
resolve: 'gatsby-source-graphql',
options: {
typeName: 'treApi',
fieldName: 'treApi',
url: apiEndpoint,
},
},
{
resolve: `gatsby-plugin-typegen`,
options: {
emitSchema: {
'src/__generated__/gatsby-schema.graphql': true,
'src/__generated__/gatsby-introspection.json': true,
},
emitPluginDocuments: {
'src/__generated__/gatsby-plugin-documents.graphql': true,
},
},
},
{
resolve: `gatsby-plugin-styled-components`,
},
Expand Down
119 changes: 22 additions & 97 deletions gatsby-node.js
Original file line number Diff line number Diff line change
@@ -1,101 +1,26 @@
const path = require(`path`);
const contentfulPathResolver = require('./gatsby/utils/contentfulPathResolver');
const { createResolvers } = require('./gatsby/create-resolvers');
const path = require('path');
const products = require('./products.json');

exports.createResolvers = createResolvers;
const createPageWithLocales = (
page,
{ deletePage, createPage },
withDelete = false
) => {
return new Promise(resolve => {
const newPath = page.path;

const newPage = {
...page,
path: `/en${newPath}`,
context: { ...page.context, locale: 'en-US' },
};
const newPage2 = {
...page,
path: newPath,
context: { ...page.context, locale: 'sv-SE' },
};
if (withDelete) {
deletePage(page);
}
createPage(newPage);
createPage(newPage2);
resolve();
});
};

const webshopDevices = async graphql => {
const result = await graphql(`
{
treApi {
webshopDevices(customerType: consumer, deviceType: phone) {
products {
id
urlSlug
brand
model
}
}
}
}
`);

if (result.errors) {
throw result.errors;
}

return result.data.treApi.webshopDevices.products || [];
};

exports.createPages = async ({ graphql, actions }) => {
const result = await graphql(`
query {
treApi {
contentPages {
id
urlRegex
blocks {
type
id
}
}
}
}
`);

if (result.errors) {
throw result.errors;
}

const isDevicePage = blocks =>
blocks.some(block => block.type === 'devicedetails');

const isProductListPage = blocks =>
blocks.some(block => block.type === 'productlist');

return Promise.all(
result.data.treApi.contentPages.map(async page => {
const { blocks, urlRegex, ...rest } = page;

let path = urlRegex;

if (path.includes('massesandbox')) return;
if (path.includes('cizzi')) return;
})
);
exports.createPages = async ({ graphql, actions, reporter }) => {
const { createPage } = actions;
};

// You can delete this file if you're not using it
exports.onCreatePage = ({ page, actions }) => {
if (page.path.includes('404')) {
return Promise.resolve();
}

return createPageWithLocales(page, actions, true);
exports.sourceNodes = ({ actions, createNodeId, createContentDigest }) => {
const { createNode } = actions;

products.forEach(product => {
createNode({
...product,
slug: product.displayName
.toLowerCase()
.replace(/ /g, '-')
.replace(/[^\w-]+/g, ''),
id: createNodeId(product.id),
internal: {
type: 'Product',
content: JSON.stringify(product),
contentDigest: createContentDigest(product),
},
});
});
};
31 changes: 0 additions & 31 deletions gatsby/create-resolvers.js

This file was deleted.

8 changes: 0 additions & 8 deletions gatsby/utils/contentfulPathResolver.js

This file was deleted.

Loading

0 comments on commit 164896d

Please sign in to comment.