Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

Commit

Permalink
fix: Remove duplication of pages
Browse files Browse the repository at this point in the history
  • Loading branch information
joostdecock committed Jan 29, 2022
1 parent 42939f9 commit 1b9f78e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 174 deletions.
16 changes: 0 additions & 16 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down
158 changes: 0 additions & 158 deletions gatsby-routes.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -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/',
Expand Down

0 comments on commit 1b9f78e

Please sign in to comment.