From 1b9f78e8356877290448bbe444adb8d02d96f36d Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Sat, 29 Jan 2022 17:01:32 +0100 Subject: [PATCH] fix: Remove duplication of pages Closes https://github.com/freesewing/freesewing/issues/1774 --- gatsby-node.js | 16 ----- gatsby-routes.js | 158 ----------------------------------------------- 2 files changed, 174 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index b48686225..76ebaec87 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -168,22 +168,6 @@ const createMdxPages = async function (pages, createPage, graphql, language) { file: page.node.fileAbsolutePath, }, } - // Handle duplicates in docs - if (type === 'docs' && typeof routes.duplicates[slug] !== 'undefined') { - for (let newSlug of routes.duplicates[slug]) { - pages[type][newSlug] = { - path: newSlug, - component, - context: { - slug: newSlug, - title: pages.docs[slug].context.title, - order: pages.docs[slug].context.order, - // Keep file here, it is used in the page query to filter - file: pages.docs[slug].context.file, - }, - } - } - } } } for (let slug in pages[type]) { diff --git a/gatsby-routes.js b/gatsby-routes.js index aa805b244..98a564684 100644 --- a/gatsby-routes.js +++ b/gatsby-routes.js @@ -1,161 +1,4 @@ const patterns = require('@freesewing/pattern-info').list -const options = require('@freesewing/pattern-info').options - -const addDupe = (option, from, to) => { - let slug = `/docs/patterns/${from}/options/${option.toLowerCase()}/` - if (!patternOptions[slug]) patternOptions[slug] = { find: from, replace: [to] } - else patternOptions[slug].replace.push(to) -} - -// this will be populated by addDupe() -const patternOptions = {} - -const dupes = { - brian: [ - { - options: [ - 'sleevecapbackfactorx', - 'sleevecapbackfactory', - 'sleevecapease', - 'sleevecapfrontfactorx', - 'sleevecapfrontfactory', - 'sleevecapq1offset', - 'sleevecapq1spread1', - 'sleevecapq1spread2', - 'sleevecapq2offset', - 'sleevecapq2spread1', - 'sleevecapq2spread2', - 'sleevecapq3offset', - 'sleevecapq3spread1', - 'sleevecapq3spread2', - 'sleevecapq4offset', - 'sleevecapq4spread1', - 'sleevecapq4spread2', - 'sleevecaptopfactorx', - 'sleevecaptopfactory', - 'sleevewidthguarantee', - ], - to: ['huey', 'simon', 'simone', 'sven', 'diana', 'teagan'], - }, - { - options: ['backneckcutout', 'frontarmholedeeper', 'shoulderslopereduction'], - to: ['bent', 'carlita', 'carlton', 'huey', 'hugo', 'jaeger', 'simon', 'sven'], - }, - { - options: ['sleevelengthbonus'], - to: ['huey', 'hugo'], - }, - { - options: ['sleevecapheight'], - to: ['carlita', 'carlton', 'jaeger'], - }, - { - options: ['acrossbackfactor'], - to: ['bent', 'diana', 'huey', 'hugo', 'teagan'], - }, - { - options: ['armholedepthfactor'], - to: ['bent', 'huey', 'sven', 'wahid', 'teagan'], - }, - { - options: ['acrossbackfactor'], - to: ['bent', 'diana', 'huey', 'hugo', 'teagan'], - }, - { - options: ['bicepsease'], - to: ['bent', 'huey', 'hugo', 'jaeger'], - }, - { - options: ['chestease', 'cuffease', 'lengthbonus'], - to: ['bent', 'huey', 'hugo'], - }, - { - options: ['collarease'], - to: ['bent', 'huey', 'jaeger', 'sven'], - }, - { - options: ['shoulderease'], - to: ['bent', 'huey', 'jaeger', 'simon'], - }, - ], - huey: [ - { - options: ['ribbingheight'], - to: ['hugo'], - }, - ], - carlita: [ - { - options: [ - 'frontoverlap', - 'pocketradius', - 'innerpocketdepth', - 'innerpocketplacement', - 'innerpocketweltheight', - 'innerpocketwidth', - 'lapelreduction', - ], - to: ['carlton', 'jaeger'], - }, - ], - titan: [ - { - options: [ - 'waistease', - 'seatease', - 'kneeease', - 'waistheight', - 'lengthbonus', - 'crotchdrop', - 'crossseamcurvestart', - 'crossseamcurvebend', - 'crossseamcurveangle', - 'crotchseamcurvestart', - 'crotchseamcurvebend', - 'crotchseamcurveangle', - 'grainlineposition', - 'legbalance', - 'waistbalance', - 'waistbandwidth', - ], - to: ['paco', 'charlie'], - }, - ], -} - -for (let from in dupes) { - for (let set of dupes[from]) { - for (let to of set.to) { - for (let option of set.options) addDupe(option, from, to) - } - } -} - -// Breanna inherits almost all options from Brian -for (let option of options.brian) { - if (['lengthBonus', 'sleeveWidthGuarantee'].indexOf(option) === -1) - addDupe(option, 'brian', 'breanna') -} - -// Carton inherits almost all options from Carlita -for (let option of options.carlita) { - if (option !== 'contour') addDupe(option, 'carlita', 'carlton') -} - -// Simone inherits all options from Simon -for (let option of options.simon) addDupe(option, 'simon', 'simone') - -const getDuplicates = () => { - let dupes = {} - for (let slug in patternOptions) { - dupes[slug] = [] - for (let insert of patternOptions[slug].replace) { - dupes[slug].push(slug.replace(patternOptions[slug].find, insert)) - } - } - - return dupes -} /* This matches a route pattern with the page component */ const routes = { @@ -211,7 +54,6 @@ const routes = { '/patterns/:pattern/save-as': 'patterns/_pattern/save-as.js', '/recreate/gist/:gist': 'recreate/gist/_gist.js', }, - duplicates: getDuplicates(), redirects: { '/recreate/': '/create/', '/contact/': '/docs/about/contact/',